{"record":{"id":"1d4f2094651184ad","repo":"Hmbown/CodeWhale","slug":"deepseek-api-key-not-found-1-get-a-key-https","errorCode":null,"errorMessage":"DeepSeek API key not found.\n\n1. Get a key:  https://platform.deepseek.com/api_keys\n2. Save it (works in every folder, no OS prompts):\ncodewhale auth set --provider deepseek\n\nAlternatives:\n• export DEEPSEEK_API_KEY=<your-key>      (current shell only;\nalso note: zsh users — exports in ~/.zshrc only reach interactive\nshells, prefer ~/.zshenv for everything)\n• api_key = \"<your-key>\"  in ~/.codewhale/config.toml\n• already configured DeepSeek Harness? grant read-only access:\ncodewhale auth external-consent --provider deepseek --mode read-only","messagePattern":"DeepSeek API key not found\\.\n\n1\\. Get a key:  https://platform\\.deepseek\\.com/api_keys\n2\\. Save it \\(works in every folder, no OS prompts\\):\ncodewhale auth set --provider deepseek\n\nAlternatives:\n• export DEEPSEEK_API_KEY=<your-key>      \\(current shell only;\nalso note: zsh users — exports in ~/\\.zshrc only reach interactive\nshells, prefer ~/\\.zshenv for everything\\)\n• api_key = \"<your-key>\"  in ~/\\.codewhale/config\\.toml\n• already configured DeepSeek Harness\\? grant read-only access:\ncodewhale auth external-consent --provider deepseek --mode read-only","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":6659,"sourceCode":"            && (provider_route_is_keyless_self_hosted(provider, &self.deepseek_base_url())\n                || base_url_uses_local_host(&self.deepseek_base_url()))\n        {\n            return Ok(String::new());\n        }\n\n        if custom_endpoint {\n            let route_name = self\n                .provider\n                .as_deref()\n                .unwrap_or_else(|| provider.as_str());\n            anyhow::bail!(\n                \"Custom endpoint credentials for {route_name} must be bound explicitly. Ambient provider credentials are not sent to {}. Add api_key or api_key_env to this provider route, or pass --api-key with --base-url.\",\n                self.deepseek_base_url()\n            );\n        }\n\n        match provider {\n            ApiProvider::Deepseek | ApiProvider::DeepseekCN => anyhow::bail!(\n                \"DeepSeek API key not found.\\n\\\n                 \\n\\\n                 1. Get a key:  https://platform.deepseek.com/api_keys\\n\\\n                 2. Save it (works in every folder, no OS prompts):\\n\\\n                        codewhale auth set --provider deepseek\\n\\\n                 \\n\\\n                 Alternatives:\\n\\\n                   • export DEEPSEEK_API_KEY=<your-key>      (current shell only;\\n\\\n                     also note: zsh users — exports in ~/.zshrc only reach interactive\\n\\\n                     shells, prefer ~/.zshenv for everything)\\n\\\n                   • api_key = \\\"<your-key>\\\"  in ~/.codewhale/config.toml\\n\\\n                   • already configured DeepSeek Harness? grant read-only access:\\n\\\n                        codewhale auth external-consent --provider deepseek --mode read-only\"\n            ),\n            ApiProvider::SiliconflowCn => anyhow::bail!(\n                \"SiliconFlow China API key not found. Get a key: {}. Run 'codewhale auth set --provider siliconflow-CN', \\\n                 set {}, or add [{}] api_key in ~/.codewhale/config.toml. \\\n                 [providers.siliconflow] remains a fallback when the CN table omits api_key.\",","sourceCodeStart":6641,"sourceCodeEnd":6677,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/config.rs#L6641-L6677","documentation":"The DeepSeek/DeepSeek-CN credential resolution chain found no usable key and ended in this guided bail. The chain covers the explicit override path, [providers.deepseek] api_key, the durable auth store, the DEEPSEEK_API_KEY environment variable, and read-only external consent for an existing DeepSeek Harness file. The message lists each remediation with exact commands, including the zsh note that exports in ~/.zshrc only reach interactive shells.","triggerScenarios":"provider is ApiProvider::Deepseek or ApiProvider::DeepseekCN, no custom endpoint, and every source in the resolution chain is empty: no --api-key, no configured api_key, nothing in the auth store, DEEPSEEK_API_KEY unset or blank, and no external-consent grant for the Harness credential file.","commonSituations":"First run after installing Codewhale; a key exported in one terminal but the TUI launched from another (or from a launcher that does not source the shell env); zsh users putting exports in ~/.zshrc where GUI-launched processes never see them; running 'codewhale auth logout' which clears stored keys.","solutions":["Run 'codewhale auth set --provider deepseek' and paste the key (works in every folder, no OS prompts)","Export DEEPSEEK_API_KEY in ~/.zshenv (zsh) or your login profile so non-interactive launches inherit it","Add 'api_key = \"sk-...\"' under [providers.deepseek] (or [providers.deepseek-cn]) in ~/.codewhale/config.toml","If DeepSeek Harness is already configured on the machine, grant read-only file access: codewhale auth external-consent --provider deepseek --mode read-only"],"exampleFix":"# before\n$ export DEEPSEEK_API_KEY=   # empty\n$ codewhale\n# error: DeepSeek API key not found...\n\n# after\n$ codewhale auth set --provider deepseek\n$ codewhale","handlingStrategy":"validation","validationCode":"// Pre-flight check before starting the TUI/CLI on a DeepSeek route:\nuse std::env;\n\nfn deepseek_credential_present(config: &Config) -> bool {\n    let route_key = config.provider_config_for(ApiProvider::Deepseek)\n        .and_then(|e| e.api_key.as_deref())\n        .is_some_and(|k| !k.trim().is_empty());\n    let env_key = env::var(\"DEEPSEEK_API_KEY\").is_ok_and(|v| !v.trim().is_empty());\n    route_key || env_key || auth_store_has(ApiProvider::Deepseek)\n}","typeGuard":null,"tryCatchPattern":"match config.deepseek_api_key() {\n    Err(e) if e.to_string().contains(\"DeepSeek API key not found\") => {\n        // run `codewhale auth set --provider deepseek` interactively, then retry startup\n    }\n    other => other?,\n}","preventionTips":["Run 'codewhale auth set --provider deepseek' once per machine instead of relying on shell exports","zsh users: export DEEPSEEK_API_KEY from ~/.zshenv so non-interactive launches inherit it","CI wrappers should fail fast with a clear message when DEEPSEEK_API_KEY is missing rather than launching the TUI"],"tags":["deepseek","credentials","auth","env-var"],"backgroundTag":"missing-api-key","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}