Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
P2Medium — degraded but workaround existsMedium — degraded but workaround existscomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointprovider/kimiKimi / MoonshotKimi / Moonshotsweeper:implemented-on-mainSweeper: behavior already present on current mainSweeper: behavior already present on current maintype/bugSomething isn't workingSomething isn't working
Description
Bug Description
Environment
- Hermes version: v0.16.0
- Provider:
kimi-coding - Model:
kimi-k2.6 - API key type:
sk-kimi-*(Kimi Code / Coding Agent key)
Problem
When using a sk-kimi-* key with provider: kimi-coding, all API calls fail with 401 Invalid Authentication.
Consequently, vision tasks also break because the requests never reach the model.
This happens even though the same sk-kimi-* key works fine in other Coding Agents (e.g. OpenClaw, Claude Code, Roo Code).
Root cause
The bundled kimi-coding provider profile currently points to:
base_url="https://api.moonshot.ai/v1"
default_headers={"User-Agent": "hermes-agent/1.0"}
However, sk-kimi-* keys are Kimi Code keys and are only accepted by the api.kimi.com/coding endpoint.
Furthermore, that endpoint requires User-Agent: claude-code/0.1.0 (or another recognised Coding Agent UA) to pass authorisation.
Verified combinations:
┌─────────────────────────────────────────┬───────────────────┬────────┐
│ Endpoint │ User-Agent │ Result │
├─────────────────────────────────────────┼───────────────────┼────────┤
│ api.moonshot.ai/v1/chat/completions │ hermes-agent/1.0 │ 401 ❌ │
│ api.kimi.com/coding/v1/chat/completions │ hermes-agent/1.0 │ 403 ❌ │
│ api.kimi.com/coding/v1/chat/completions │ claude-code/0.1.0 │ 200 ✅ │
│ api.kimi.com/coding/v1/messages │ claude-code/0.1.0 │ 200 ✅ │
└─────────────────────────────────────────┴───────────────────┴────────┘
Note: api.kimi.com/coding supports both OpenAI and Anthropic wire protocols; the protocol choice is not the issue. The issue is the wrong endpoint and missing Coding-Agent User-Agent.
Suggested fix
─────────────
Update plugins/model-providers/kimi-coding/__init__.py:
base_url="https://api.kimi.com/coding",
default_headers={"User-Agent": "claude-code/0.1.0"},
And apply the same change to kimi-coding-cn.
Related
───────
The _endpoint_speaks_anthropic_messages() helper in agent/auxiliary_client.py explicitly avoids forcing Anthropic wrapping for api.kimi.com/coding because kimi-k2.6 supports vision via OpenAI wire. This is correct — the fix should keep the OpenAI wire and only change the endpoint + User-Agent.
Workaround (for users)
──────────────────────
Until this is merged, override in config.yaml:
model:
provider: kimi-coding
base_url: https://api.kimi.com/coding
# Also update auxiliary.vision if configured
auxiliary:
vision:
provider: custom
base_url: https://api.kimi.com/coding
model: kimi-k2.6
And patch the User-Agent in the provider profile or via a local proxy.
### Steps to Reproduce
1.run hermes agent
2.send a img to analyzing
### Expected Behavior
smoothly understanding image
### Actual Behavior
output a 401/ 403 error
### Affected Component
Configuration (config.yaml, .env, hermes setup)
### Messaging Platform (if gateway-related)
_No response_
### Debug Report
```shell
Debug report uploaded:
Report https://paste.rs/x5Dlz
agent.log https://paste.rs/Klveu
gateway.log https://paste.rs/sbwPKOperating System
macOS 26.5
Python Version
No response
Hermes Version
0.16.0
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
No response
Proposed Fix (optional)
No response
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Metadata
Metadata
Assignees
Labels
P2Medium — degraded but workaround existsMedium — degraded but workaround existscomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointprovider/kimiKimi / MoonshotKimi / Moonshotsweeper:implemented-on-mainSweeper: behavior already present on current mainSweeper: behavior already present on current maintype/bugSomething isn't workingSomething isn't working
Activity
liuhao1024 commentedon Jun 11, 2026
This is fixed by #43629 — switches the kimi-coding provider's base URL to
api.kimi.com/codingto match the correct API endpoint.AIalliAI commentedon Jun 12, 2026
Triaged this against the v2026.6.5 release (the
v0.16.0you report running) and current main. The 401 you hit may well be real on your machine, but the proposed root cause doesn't match what ships in v0.16.0, and the suggested profile edit would regress other users.1. v0.16.0 already routes
sk-kimi-*keys toapi.kimi.com/coding.hermes_cli/auth.pyat the v2026.6.5 tag has_resolve_kimi_base_url()(L518) withKIMI_CODE_BASE_URL = "https://api.kimi.com/coding"(L515): any key starting withsk-kimi-is auto-redirected to the coding endpoint unlessKIMI_BASE_URLexplicitly overrides. It's applied at both credential-resolution call sites and inagent/credential_pool.py. The interactive setup flow (_model_flow_kimiinhermes_cli/model_setup_flows.py) prints "Detected Kimi Coding Plan key → api.kimi.com/coding" and even clears staleKIMI_BASE_URLoverrides. Theapi.moonshot.ai/v1default in the provider profile is intentional — it's the endpoint for legacy platform.moonshot.ai keys, per the comment right above the registry entry (auth.py L253).2. The User-Agent is host-keyed, not profile-keyed. Requests to
api.kimi.comgetUser-Agent: claude-code/0.1.0regardless of profile defaults —run_agent.py(base_url_host_matches(base_url, "api.kimi.com")→ sets the header),agent/anthropic_adapter.py,agent/agent_init.py, and the auxiliary client all do this in v2026.6.5. A correctly-routed request never reachesapi.kimi.comcarryinghermes-agent/1.0.3. The "Related" note inverts what the code does.
_endpoint_speaks_anthropic_messages()returns True forapi.kimi.com/coding— it forces Anthropic Messages transport there; its docstring says the /coding route "only speaks Claude-Code's native Anthropic shape". It does not "avoid forcing Anthropic wrapping" for that endpoint.4. Vision on kimi-coding doesn't 401 — it's deny-listed.
kimi-coding/kimi-coding-cnare in_PROVIDERS_WITHOUT_VISION(agent/auxiliary_client.py), soauxiliary.vision: autoskips Kimi and falls through to the aggregator chain — that's the #17076 fix. Whether the /coding endpoint now accepts image input is exactly what the existing kimi-vision cluster is litigating (#6611 canonical; open PRs #18999/#23658 propose lifting the deny-list) — fresh capability evidence is most useful there.5. The proposed fix regresses other users. Hardcoding
base_url="https://api.kimi.com/coding"in the profile (what #43629 does) breaks every legacy platform.moonshot.ai key —api.moonshot.ai/v1is their only working endpoint — and pointingkimi-coding-cnat the globalapi.kimi.comdefeats the CN variant (api.moonshot.cn) entirely.sk-kimi-*keys gain nothing, since they're already redirected.To pin down your actual 401 — both paste.rs debug links are 404 now; could you re-upload? Also useful:
hermes --version(pre-v2026.6.5 builds predate the auto-redirect),KIMI_BASE_URLis set in your env/.env (an explicit override wins over auto-detection),base_urlfrom an older install,hermes doctoroutput (it prints the resolved Kimi endpoint).If one of those shows the redirect being bypassed on a clean v0.16.0, that's a real bug worth fixing at the resolution layer — but not by repointing the profile defaults.
kevin-lucifer commentedon Jun 12, 2026
补充:vision 路由问题
额外发现
在排查 Kimi Code Plan 的 vision 支持时,我们发现除了 #43617 提到的端点问题,还有 vision 路由 需要修复:
当前问题
即使 #43617 修复了主模型的端点,auxiliary vision 仍然需要手动配置 workaround:
期望行为
当主 provider 是 且用户配置了 Code Plan API key,vision 应该自动使用正确的 OpenAI 兼容端点,无需手动配置 。
根因分析
建议修复
在 的 或 中:
或者更通用的方案:为 provider 添加 vision 专用的端点配置。
相关
cc @Teknium
AIalliAI commentedon Jun 12, 2026
@kevin-lucifer — a few claims in the supplement don't match the current state of main (checked just now at 46d758b):
1. The deny-list removal has not happened.
kimi-codingandkimi-coding-cnare both still in_PROVIDERS_WITHOUT_VISION(agent/auxiliary_client.py:342on main). #18990 is an open issue requesting that removal, and #18999 / #23658 are the open PRs that would implement it — none of them has merged. So "已移除(感谢 #18990)" is premature; the removal is still pending capability evidence in the #6611 cluster.2. Because the deny-list is intact, there is no vision request to mis-route today. With
auxiliary.vision: auto, kimi-coding is deliberately skipped and vision falls through to the aggregator chain (the #17076 fix). The "vision should auto-use the OpenAI-compatible endpoint" routing question only becomes live if/when the deny-list is lifted — which is exactly what #18999/#23658 (and the capability dispute in #6611/#26938) need to settle first. Fresh curl evidence thatapi.kimi.com/codingaccepts image input would be most useful posted there.3. Several inline code spans in your comment rendered empty (the credential-pool value, the proposed fix location, the suggested config key), so the "credential pool 中的 … 仍然是 …(Anthropic 格式)" claim can't be evaluated as posted. Could you re-post with the literal paths and values? For reference: base-URL resolution for
sk-kimi-*keys already pinshttps://api.kimi.com/codingvia_resolve_kimi_base_url()(hermes_cli/auth.py) at both credential-resolution call sites and inagent/credential_pool.py, and theclaude-code/0.1.0User-Agent is host-keyed toapi.kimi.com— see my comment above for the line-level cites.4. #45040 was closed in favor of consolidating the Kimi vision discussion into the existing cluster (#6611 canonical, with #18999/#23658/#24681/#26938) — that's the right home for the auto-detection design, rather than this endpoint-routing issue, whose root-cause claim doesn't hold on v0.16.0 (see above).
kevin-lucifer commentedon Jun 18, 2026
@AIalliAI 感谢之前的审阅。我们又做了端到端验证,现在 Kimi Code Plan 的视觉可以跑通了,问题根因和之前讨论的不完全一样。把证据和补丁贴一下:
跑通的配置
.env里只有一行KIMI_API_KEY=sk-kimi-...。之前失败的原因
不是端点选错,也不是
/coding/v1不接受 vision,而是 auxiliary vision 没有拿到 API key。当
auxiliary.vision同时配置了provider: kimi-coding和base_url: https://api.kimi.com/coding/v1但api_key留空时,Hermes 内部把它降级成provider: custom,进入 custom 分支。custom 分支只检查explicit_api_key或OPENAI_API_KEY,找不到就 fallback 成no-key-required,导致请求带Authorization: Bearer no-key-required,Kimi 返回 401:修复内容
在
resolve_provider_client()的 custom 分支里,当没有显式 key 时,从 endpoint hostname 反推 provider(api.kimi.com/coding/v1→kimi-coding),然后走resolve_api_key_provider_credentials()从KIMI_API_KEY读取 key。这样既保留用户显式指定端点的灵活性,又不需要在config.yaml里重复写 key。另外把
kimi/moonshot/kimi-cn/moonshot-cn这些 alias 也纳入 native vision 的 skip 列表,避免主模型端点/coding被误当作支持 vision。验证结果
vision_analyze_tool('file:///tmp/small_test.jpg', ...)也成功返回分析。PR
补丁已提交到 #48509,改动文件只有
agent/auxiliary_client.py、agent/image_routing.py和对应测试,没有包含任何明文 API key。teknium1 commentedon Jul 14, 2026
Thanks for the detailed report. This is already implemented on current
main; automated hermes-sweeper review confirmed both the original routing/header fix and the later auxiliary-endpoint scenario.hermes_cli/auth.py:523routessk-kimi-*keys tohttps://api.kimi.com/coding; the legacy Moonshot URL remains only for legacy keys.run_agent.py:4441andagent/auxiliary_client.py:4927applyUser-Agent: claude-code/0.1.0forapi.kimi.com.kimi-codingrather than flattening it tocustom(agent/auxiliary_client.py:5969), so its normalKIMI_API_KEYresolution and Kimi transport handling remain active. This was added bya8841e2a6877f7b5e7b4b6ab0122ef2fde229fe2.tests/agent/test_auxiliary_transport_autodetect.py:228andtests/hermes_cli/test_api_key_providers.py:885.The original Kimi Code routing support is present in ancestor commit
4447e7d71afaa9840e02469c6296c7e2604b3ea5.