{"record":{"id":"f8c402284ac0d8cb","repo":"Hmbown/CodeWhale","slug":"siliconflow-china-api-key-not-found-get-a-key","errorCode":null,"errorMessage":"SiliconFlow China API key not found. Get a key: {}. Run 'codewhale auth set --provider siliconflow-CN', set {}, or add [{}] api_key in ~/.codewhale/config.toml. [providers.siliconflow] remains a fallback when the CN table omits api_key.","messagePattern":"SiliconFlow China API key not found\\. Get a key: (.+?)\\. Run 'codewhale auth set --provider siliconflow-CN', set (.+?), or add \\[(.+?)\\] api_key in ~/\\.codewhale/config\\.toml\\. \\[providers\\.siliconflow\\] remains a fallback when the CN table omits api_key\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":7352,"sourceCode":"                    .credential_url()\n                    .unwrap_or(\"https://app.codewhale.net/settings?section=api\")\n            ),\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.\",\n                provider\n                    .credential_url()\n                    .unwrap_or(\"https://cloud.siliconflow.com/account/ak\"),\n                provider.env_vars_label(),\n                provider_config_table_name(provider)?\n            ),\n            ApiProvider::Moonshot => {\n                let credential_help =\n                    credential_help_for_provider_route(provider, &self.active_route_base_url());\n                if moonshot_base_url_is_exact_kimi_code(&self.active_route_base_url()) {\n                    anyhow::bail!(\n                        \"Kimi Code membership-plan API key not found. Get a plan key: {}. This route uses api.kimi.com/coding/v1 and does not import Kimi CLI credentials. Run 'codewhale auth set --provider moonshot', set {}, or add [{}] api_key.\",\n                        credential_help\n                            .credential_url\n                            .unwrap_or(KIMI_CODE_MEMBERSHIP_PLAN_CONSOLE_URL),","sourceCodeStart":7334,"sourceCodeEnd":7370,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L7334-L7370","documentation":"The SiliconFlow China (siliconflow-CN) route requires its own API key. The resolver first consults the CN provider table; if it finds no key there it fails, noting that [providers.siliconflow] (the global endpoint) still acts as a fallback when the CN table omits api_key.","triggerScenarios":"Provider resolves to ApiProvider::SiliconflowCn and neither the CN provider table, the SiliconFlow CN env var, nor config api_key supplies a credential.","commonSituations":"Users of the global SiliconFlow endpoint switching to the China region without creating a China-region key (the two regions use separate accounts/keys); env var typo'd or set only in an interactive shell.","solutions":["Get a key at https://cloud.siliconflow.com/account/ak and run: codewhale auth set --provider siliconflow-CN","Set the SiliconFlow CN env var shown in the error in the launching shell.","Add [providers.siliconflow-CN] api_key = \"...\" in ~/.codewhale/config.toml.","Or ensure [providers.siliconflow] has api_key so the documented fallback applies when the CN table omits api_key."],"exampleFix":"// before\n[providers.siliconflow-CN]\nbase_url = \"https://api.siliconflow.cn/v1\"\n\n// after\n[providers.siliconflow-CN]\nbase_url = \"https://api.siliconflow.cn/v1\"\napi_key = \"sk-...\"","handlingStrategy":"validation","validationCode":"fn cn_route_has_key(cfg: &toml::Value) -> bool {\n    cfg.get(\"providers\").map(|p| {\n        p.get(\"siliconflow-CN\").and_then(|c| c.get(\"api_key\")).is_some()\n            || p.get(\"siliconflow\").and_then(|c| c.get(\"api_key\")).is_some()\n    }).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"SiliconFlow China API key not found\") => {\n        eprintln!(\"create a China-region key at cloud.siliconflow.com and add [providers.siliconflow-CN] api_key\");\n    }\n    other => other?,\n}","preventionTips":["Remember global and China SiliconFlow accounts are separate — a global key never works on -CN routes.","Keep [providers.siliconflow] api_key populated so the documented fallback applies.","Verify the CN table's api_key after switching regions."],"tags":["api-key","siliconflow","china-region","config"],"backgroundTag":"missing-api-key","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}