{"record":{"id":"bc971b7d4c185954","repo":"Hmbown/CodeWhale","slug":"moonshot-kimi-api-key-not-found-get-a-key-ru","errorCode":null,"errorMessage":"Moonshot/Kimi API key not found. Get a key: {}. Run 'codewhale auth set --provider moonshot', set {}, or add [{}] api_key. For a Kimi Code plan key, set [providers.moonshot] base_url = \"https://api.kimi.com/coding/v1\" and model = \"kimi-for-coding\".","messagePattern":"Moonshot/Kimi API key not found\\. Get a key: (.+?)\\. Run 'codewhale auth set --provider moonshot', set (.+?), or add \\[(.+?)\\] api_key\\. For a Kimi Code plan key, set \\[providers\\.moonshot\\] base_url = \"https://api\\.kimi\\.com/coding/v1\" and model = \"kimi-for-coding\"\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":7375,"sourceCode":"                    .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),\n                        provider.env_vars_label(),\n                        provider_config_table_name(provider)?\n                    );\n                }\n                anyhow::bail!(\n                    \"Moonshot/Kimi API key not found. Get a key: {}. Run 'codewhale auth set --provider moonshot', \\\n                     set {}, or add [{}] api_key. \\\n                     For a Kimi Code plan key, set [providers.moonshot] base_url = \\\n                     \\\"https://api.kimi.com/coding/v1\\\" and model = \\\"kimi-for-coding\\\".\",\n                    credential_help\n                        .credential_url\n                        .unwrap_or(\"https://platform.kimi.ai/console/api-keys\"),\n                    provider.env_vars_label(),\n                    provider_config_table_name(provider)?\n                );\n            }\n            ApiProvider::Anthropic | ApiProvider::Openmodel => {\n                anyhow::bail!(\"{}\", missing_provider_api_key_message(provider)?)\n            }\n            ApiProvider::OpencodeZen => {\n                anyhow::bail!(\"{}\", missing_provider_api_key_message(provider)?)\n            }\n            ApiProvider::OpenaiCodex => anyhow::bail!(","sourceCodeStart":7357,"sourceCodeEnd":7393,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L7357-L7393","documentation":"Generic Moonshot/Kimi routes require a standard Moonshot platform API key. When no credential is found in overrides, env, config, or the secret store, the resolver bails and also explains how to opt into the Kimi Code plan endpoint if that was the intent.","triggerScenarios":"Provider is ApiProvider::Moonshot, the base URL is not exactly api.kimi.com/coding/v1, and no API key is present via --api-key, MOONSHOT/KIMI env vars, [providers.moonshot] api_key/api_key_env, or stored auth.","commonSituations":"Fresh Moonshot account setup; deleting a stored key via logout; intending to use a Kimi Code plan but leaving the default base_url so the plan key is never looked up on the right route.","solutions":["Get a key at the Moonshot/Kimi platform console and run: codewhale auth set --provider moonshot","Set MOONSHOT_API_KEY (or the env var listed by env_vars_label) in the environment that launches codewhale.","Add api_key = \"...\" under [providers.moonshot] in ~/.codewhale/config.toml.","If you actually have a Kimi Code plan key, set [providers.moonshot] base_url = \"https://api.kimi.com/coding/v1\" and model = \"kimi-for-coding\"."],"exampleFix":"// before\n[providers.moonshot]\nmodel = \"kimi-k2-0711-preview\"\n\n// after\n[providers.moonshot]\nmodel = \"kimi-k2-0711-preview\"\napi_key_env = \"MOONSHOT_API_KEY\"","handlingStrategy":"validation","validationCode":"std::env::var(\"MOONSHOT_API_KEY\")\n    .ok()\n    .filter(|k| !k.trim().is_empty())\n    .ok_or_else(|| \"MOONSHOT_API_KEY missing; run codewhale auth set --provider moonshot\".to_string())?;","typeGuard":"fn moonshot_key_ready(env_val: Option<&str>) -> bool {\n    env_val.map(|k| k.starts_with(\"sk-\")).unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Moonshot/Kimi API key not found\") => {\n        eprintln!(\"run: codewhale auth set --provider moonshot\");\n    }\n    other => other?,\n}","preventionTips":["Decide up front between a standard Moonshot key and a Kimi Code plan key; the base_url determines which is needed.","Store the key via 'codewhale auth set' rather than per-shell exports.","Re-check credentials after any logout or key wipe."],"tags":["api-key","moonshot","kimi","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"}