Hmbown/CodeWhale · error · anyhow::Error
Kimi CLI credential import is unsupported. Codewhale does no
Error message
Kimi CLI credential import is unsupported. Codewhale does not impersonate or reuse Kimi OAuth clients; configure an API key from {} instead. What it means
In the provider key-resolution chain, Moonshot with the stock endpoint rejects configs whose [providers.moonshot] auth_mode selects a Kimi-CLI-imported OAuth token (provider_config_uses_kimi_imported_token). Codewhale deliberately does not impersonate Kimi's OAuth client, so the imported-token route is unsupported and fails loudly instead of silently degrading.
Source
Thrown at crates/tui/src/config.rs:6146
}
if matches!(provider, ApiProvider::Deepseek | ApiProvider::DeepseekCN)
&& self.config_credentials_are_bound_to_provider_endpoint(provider)
&& let Some(configured) = self.api_key.as_ref()
&& classify_config_api_key_value(configured) == ConfigApiKeyValueKind::Literal
{
warn_on_config_api_key_shadowing(self, provider, "the root api_key");
return Ok(configured.clone());
}
if provider == ApiProvider::Moonshot
&& !custom_endpoint
&& self
.provider_config_for(provider)
.is_some_and(provider_config_uses_kimi_imported_token)
{
let credential_help =
credential_help_for_provider_route(provider, &self.deepseek_base_url());
anyhow::bail!(
"Kimi CLI credential import is unsupported. Codewhale does not impersonate or reuse Kimi OAuth clients; configure an API key from {} instead.",
credential_help
.credential_url
.unwrap_or("the selected provider's API-key console")
);
}
// xAI OAuth prefers Codewhale-owned device-login storage. An existing
// Grok CLI file is considered only with provider/path-scoped read-only
// consent. Activated by [providers.xai] auth_mode = "oauth".
if provider == ApiProvider::Xai
&& !custom_endpoint
&& self
.provider_config_for(provider)
.is_some_and(provider_config_uses_xai_oauth)
&& crate::xai_oauth::credentials_present(self)
{
return crate::xai_oauth::get_access_token(self);View on GitHub (pinned to 8880682c63)
Solutions
- Configure a Moonshot API key instead: codewhale auth set --provider moonshot.
- Remove the imported-token auth_mode from [providers.moonshot] (delete auth_mode or replace with api_key auth).
- If you have a Kimi Code membership plan, set [providers.moonshot] base_url = "https://api.kimi.com/coding/v1" and use a plan key.
Example fix
# before [providers.moonshot] auth_mode = "kimi-imported-token" # after [providers.moonshot] api_key = "sk-..." # or: codewhale auth set --provider moonshot
Defensive patterns
Strategy: validation
Validate before calling
// reject Moonshot configs that still select Kimi token import before resolving keys
if config.provider_config_for(ApiProvider::Moonshot)
.map(|pc| pc.auth_mode.as_deref().is_some_and(auth_mode_uses_kimi_imported_token))
.unwrap_or(false)
{
anyhow::bail!("this config predates support: switch [providers.moonshot] to api_key auth");
} Type guard
fn moonshot_config_is_supported(pc: &ProviderConfig) -> bool {
!pc.auth_mode
.as_deref()
.is_some_and(auth_mode_uses_kimi_imported_token)
} Try / catch
match config.deepseek_api_key() {
Err(e) if e.to_string().contains("Kimi CLI credential import is unsupported") => {
// strip the imported-token auth_mode, then guide to codewhale auth set --provider moonshot
Err(e)
}
other => other,
} Prevention
- Do not follow old guides that import Kimi CLI OAuth tokens — they are unsupported by design.
- Prefer `codewhale auth set --provider moonshot` over any token-file scheme.
- Audit configs after upgrades for removed auth_mode values.
When it happens
Trigger: A config carried over from Kimi CLI import support with auth_mode set to a kimi-imported-token mode; provider = moonshot without a custom endpoint; no API key configured anywhere.
Common situations: Downgrading or migrating from a Kimi CLI setup; following an old guide that told users to import Kimi CLI tokens; sharing configs between tools that did support token import.
Related errors
- Kimi Code membership-plan API key not found. Get a plan key:
- Moonshot/Kimi API key not found. Get a key: {}. Run 'codewha
- parallel(): expected an array of thunks
- external credential consent for {}: {error}
- OpenAI Codex OAuth credentials are unavailable. Codewhale c
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/9bcd168a9c1d7a3f.
Report an issue: GitHub.