{"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":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":6391,"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.deepseek_base_url());\n                if moonshot_base_url_is_exact_kimi_code(&self.deepseek_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!(\"{}\", crate::oauth::missing_auth_message()),","sourceCodeStart":6373,"sourceCodeEnd":6409,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/config.rs#L6373-L6409","documentation":"The generic Moonshot/Kimi missing-key error, emitted when the base URL is NOT the exact Kimi Code endpoint. It lists the credential URL, the auth-set command, the env var, the config table, and finally the recipe to switch to the Kimi Code plan route (base_url + model = kimi-for-coding).","triggerScenarios":"provider = moonshot with the default platform endpoint and no stored key, env var, or [providers.moonshot] api_key.","commonSituations":"First-time Moonshot users; keys cleared by logout or rotated; teams whose CI lacks the MOONSHOT_API_KEY-style secret.","solutions":["Run codewhale auth set --provider moonshot.","Or export the Moonshot env var shown in the message.","Or add api_key under [providers.moonshot] in ~/.codewhale/config.toml.","If you actually hold a Kimi Code plan key, set [providers.moonshot] base_url = \"https://api.kimi.com/coding/v1\" and model = \"kimi-for-coding\" instead."],"exampleFix":"# before\nprovider = \"moonshot\"\n# no key anywhere\n\n# after (terminal)\n# codewhale auth set --provider moonshot\n# or config:\n# [providers.moonshot]\n# api_key = \"sk-...\"","handlingStrategy":"validation","validationCode":"fn moonshot_key_present(cfg: &Config) -> bool {\n    env_nonempty(\"MOONSHOT_API_KEY\") // or the env vars named by provider.env_vars_label()\n        || cfg.provider_config_for(ApiProvider::Moonshot)\n            .and_then(|pc| pc.api_key)\n            .is_some_and(|k| !k.trim().is_empty())\n        || secret_store_has(ApiProvider::Moonshot)\n}\n\nanyhow::ensure!(moonshot_key_present(&config), \"configure Moonshot auth first\");","typeGuard":"fn moonshot_credentials_configured(cfg: &Config) -> bool {\n    moonshot_key_present(cfg)\n}","tryCatchPattern":"match config.deepseek_api_key() {\n    Err(e) if e.to_string().starts_with(\"Moonshot/Kimi API key not found\") => {\n        run_auth_set(ApiProvider::Moonshot)?;\n        config.deepseek_api_key()\n    }\n    other => other,\n}","preventionTips":["Persist the key with codewhale auth set --provider moonshot rather than shell exports.","If the error suggests the Kimi Code route but you use pay-as-you-go, check for an accidental base_url override."],"tags":["rust","moonshot","kimi","api-key","authentication","config"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}