{"record":{"id":"ff3ac08435d04364","repo":"Hmbown/CodeWhale","slug":"kimi-code-membership-plan-api-key-not-found-get-a","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":7366,"sourceCode":"                   • 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),\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)?","sourceCodeStart":7348,"sourceCodeEnd":7384,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L7348-L7384","documentation":"The Kimi Code membership-plan route (api.kimi.com/coding/v1) requires a Kimi Code plan API key and, unlike generic Moonshot routes, will not import Kimi CLI credentials. When no such key is bound, credential resolution bails before any request is sent.","triggerScenarios":"Provider is ApiProvider::Moonshot and moonshot_base_url_is_exact_kimi_code() matches the active base URL (exactly https://api.kimi.com/coding/v1) while no api_key/api_key_env/env var/stored key is present.","commonSituations":"Subscribing to a Kimi Code plan and pointing base_url at the coding endpoint but never creating/pasting the plan key; expecting an existing Kimi CLI login to cover the coding endpoint.","solutions":["Get a Kimi Code plan key at the console URL in the message and run: codewhale auth set --provider moonshot","Set the Moonshot env var shown by env_vars_label() in the launching shell.","Add api_key = \"...\" under [providers.moonshot] in ~/.codewhale/config.toml.","Do not attempt Kimi CLI credential import — it is intentionally unsupported for this route."],"exampleFix":"// before\n[providers.moonshot]\nbase_url = \"https://api.kimi.com/coding/v1\"\nmodel = \"kimi-for-coding\"\n\n// after\n[providers.moonshot]\nbase_url = \"https://api.kimi.com/coding/v1\"\nmodel = \"kimi-for-coding\"\napi_key = \"sk-...\"","handlingStrategy":"validation","validationCode":"fn kimi_code_route_has_key(cfg: &ProviderCfg) -> bool {\n    cfg.base_url.as_deref() == Some(\"https://api.kimi.com/coding/v1\")\n        && (cfg.api_key.is_some() || cfg.api_key_env.is_some())\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Kimi Code membership-plan API key not found\") => {\n        eprintln!(\"get a plan key and set [providers.moonshot] api_key; kimi CLI import is unsupported\");\n    }\n    other => other?,\n}","preventionTips":["Create the Kimi Code plan key before switching base_url to api.kimi.com/coding/v1.","Never plan around Kimi CLI credential import on this route.","Set model = \"kimi-for-coding\" together with the plan key."],"tags":["api-key","moonshot","kimi-code","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"}