kimi-code
kimi-code copied to clipboard
`/login` duplicates platform API key into `managed:kimi-code` provider where it always fails — confusing startup error
Problem
When a user runs /login and enters a Kimi Platform API key (platform.kimi.ai / api.moonshot.ai), the CLI writes it to TWO places in config.toml:
[providers.moonshot-ai].api_key— where it works correctly[providers."managed:kimi-code"].api_key— which points athttps://api.kimi.com/coding/v1, a different realm that only accepts Kimi Code subscription credentials
At startup, the model-list refresh for managed:kimi-code hits api.kimi.com/coding/v1/models with the platform key and gets rejected. The user sees:
Skipped refreshing managed:kimi-code: Kimi Code models endpoint https://api.kimi.com/coding/v1 rejected the API key: The API Key appears to be invalid or may have expired.
This is confusing because:
- The key just worked moments ago in
/login - The error doesn't say which key or which endpoint failed
- The user has no way to know the platform key was duplicated into a wrong provider
Additionally, if the user previously logged in via Kimi Code OAuth, an expired OAuth token stays in ~/.kimi-code/credentials/kimi-code.json forever — never cleaned up or flagged for re-login.
Reproduction
- Start Kimi Code CLI fresh
- Run
/login, enter a platform.kimi.ai API key - See the startup banner with the "rejected the API key" warning
Expected behavior
/loginshould only write the key to the matching provider (e.g.moonshot-aifor platform keys,managed:kimi-codefor Kimi Code subscription)- The startup warning should include the provider name that failed, not a generic "the API Key"
- Expired OAuth credentials should be cleaned up or the user prompted to re-authenticate
Environment
- Kimi Code v0.41.0
- Config:
~/.kimi-code/config.toml - Credentials:
~/.kimi-code/credentials/kimi-code.json