Problem or Use Case
Moonshot AI offers two separate API surfaces for their Kimi models:
- Legacy Moonshot API —
https://api.moonshot.ai/v1 — general-purpose chat, accessed via keys from platform.moonshot.cn.
- Kimi Code API —
https://api.kimi.com/coding/v1 — coding-optimised endpoint with the latest kimi-coding and kimi-latest models, accessed via keys from platform.kimi.ai (prefixed sk-kimi-).
Currently, the kimi-coding provider in Hermes only points to api.moonshot.ai/v1, so users with Kimi Code keys (sk-kimi- prefix) get authentication failures when they try to use the provider. Additionally, the model list does not include the newer kimi-coding and kimi-latest model IDs offered by the Kimi Code endpoint.
Proposed Solution
1. Auto-detect endpoint from API key prefix
When KIMI_BASE_URL is not explicitly set, inspect the key:
- Keys prefixed
sk-kimi- → route to https://api.kimi.com/coding/v1
- All other keys → route to
https://api.moonshot.ai/v1 (legacy fallback)
This is transparent and requires no user action beyond pasting their key.
2. Extend the model list
Add the models available on the Kimi Code endpoint:
"kimi-coding": [
"kimi-coding", # latest coding-optimised model
"kimi-latest", # latest general model on kimi.com
"kimi-k2.5",
"kimi-k2-thinking",
"kimi-k2-turbo-preview",
"kimi-k2-0905-preview",
]
3. Update the setup wizard
Show both endpoints to the user, auto-detect which endpoint a just-entered key routes to, and confirm the endpoint in the success message:
✓ Kimi API key saved (Kimi Coding endpoint: https://api.kimi.com/coding/v1)
4. Add context window metadata
Register correct context lengths in agent/model_metadata.py:
kimi-coding: 200,000 tokens
kimi-latest: 200,000 tokens
Alternatives Considered
- Require users to manually set
KIMI_BASE_URL — This is the current state and it causes confusion. Auto-detection is strictly better UX with no downside.
- Separate provider ID for the coding endpoint — Unnecessary complexity; the same
kimi-coding provider ID can serve both endpoints transparently.
Affected Files
| File |
Change |
hermes_cli/auth.py |
_resolve_kimi_base_url() helper + KIMI_CODE_BASE_URL constant; wire into resolve_api_key_provider_credentials() |
hermes_cli/models.py |
Add kimi-coding and kimi-latest to _PROVIDER_MODELS["kimi-coding"] |
hermes_cli/setup.py |
Show both endpoint URLs; feedback on key type in setup wizard |
agent/model_metadata.py |
Context lengths for kimi-coding (200k) and kimi-latest (200k) |
Feature Type
Configuration option
Scope
Medium (few files, < 300 lines)
Contribution
Problem or Use Case
Moonshot AI offers two separate API surfaces for their Kimi models:
https://api.moonshot.ai/v1— general-purpose chat, accessed via keys fromplatform.moonshot.cn.https://api.kimi.com/coding/v1— coding-optimised endpoint with the latestkimi-codingandkimi-latestmodels, accessed via keys fromplatform.kimi.ai(prefixedsk-kimi-).Currently, the
kimi-codingprovider in Hermes only points toapi.moonshot.ai/v1, so users with Kimi Code keys (sk-kimi-prefix) get authentication failures when they try to use the provider. Additionally, the model list does not include the newerkimi-codingandkimi-latestmodel IDs offered by the Kimi Code endpoint.Proposed Solution
1. Auto-detect endpoint from API key prefix
When
KIMI_BASE_URLis not explicitly set, inspect the key:sk-kimi-→ route tohttps://api.kimi.com/coding/v1https://api.moonshot.ai/v1(legacy fallback)This is transparent and requires no user action beyond pasting their key.
2. Extend the model list
Add the models available on the Kimi Code endpoint:
3. Update the setup wizard
Show both endpoints to the user, auto-detect which endpoint a just-entered key routes to, and confirm the endpoint in the success message:
4. Add context window metadata
Register correct context lengths in
agent/model_metadata.py:kimi-coding: 200,000 tokenskimi-latest: 200,000 tokensAlternatives Considered
KIMI_BASE_URL— This is the current state and it causes confusion. Auto-detection is strictly better UX with no downside.kimi-codingprovider ID can serve both endpoints transparently.Affected Files
hermes_cli/auth.py_resolve_kimi_base_url()helper +KIMI_CODE_BASE_URLconstant; wire intoresolve_api_key_provider_credentials()hermes_cli/models.pykimi-codingandkimi-latestto_PROVIDER_MODELS["kimi-coding"]hermes_cli/setup.pyagent/model_metadata.pykimi-coding(200k) andkimi-latest(200k)Feature Type
Configuration option
Scope
Medium (few files, < 300 lines)
Contribution