fix(proxy): bypass Kimi Coding Plan User-Agent whitelist for non-whitelisted agents#3671
fix(proxy): bypass Kimi Coding Plan User-Agent whitelist for non-whitelisted agents#3671pgao-cn wants to merge 1 commit into
Conversation
…elisted agents
Kimi Coding Plan (api.kimi.com/coding/v1) enforces a strict User-Agent
whitelist. Verified via curl testing:
- ✅ whitelisted: claude-cli/*, claude-code/*, Kilo-Code/*
- ❌ rejected: codex-cli/*, kimi-cli/*, openclaw/*
This fix injects a whitelisted User-Agent (claude-cli/{version}) for
all requests to Kimi endpoints when the original agent (Codex, OpenCode,
Gemini, Hermes, OpenClaw) is not on the whitelist.
Claude Code retains its original claude-cli/{version} UA since it is
already whitelisted.
Fixes 403 Forbidden: 'Kimi For Coding is currently only available for
Coding Agents such as Kimi CLI, Claude Code, Roo Code, Kilo Code, etc.'
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
期待合入 支持 kimi code plan |
|
Would it also be possible to add a feature to Claude Code that allows modifying the User-Agent? The reason I ask is that some relay services only accept Codex's User-Agent when running GPT models, and only accept Claude CLI's User-Agent when using Claude models. This means that every time I switch models, I have to switch to a different CLI as well, and I lose all my conversation history in the process. It would be really helpful if Claude Code could support custom User-Agents. |
|
Hi @farion1231, this PR has passed all CI checks and Codex review without any major issues. Could you please take a look when you have a moment? Thanks! 🙏 |
|
Hope to speed up the progress |
等不及了 |
期待合并,不理解 kimi 的风控逻辑,为了防中转站使用 kimi for coding 就只从 UA 识别一刀切了其他 Agent 使用的可能吗,就没有更好的方式了吗,而且这种伪造 UA 的方式是 work 的 |
|
我使用某些api中转站时也有自定义请求头的需求, 不应该只因为 kimi 的风控政策影响其它中转站的使用 |
…ettings Polish the provider-level User-Agent override UI on the Claude and Codex forms. - Add a shared CustomUserAgentField (label + input + preset dropdown + live validation) so both forms stay in sync. - Provide curated UA presets (Claude Code / Kilo Code families that pass coding-plan UA whitelists per #3671); the first is Claude Code's real `claude-cli/x (external, cli)` format. Whitelists gate on the name prefix, not the version, so static values stay valid across upgrades. - Expose presets via a dropdown to the right of the input (z-[200] so it renders above the dialog layers) instead of inline chips. - Move the field into the existing advanced/reasoning collapsibles. - userAgent.ts mirrors the backend byte rule (reject only control chars; non-ASCII is allowed) for a non-blocking inline hint. - i18n for all four locales (zh/en/ja/zh-TW).
|
新版本已经支持了自定义请求头了 Kimi 可以接入了 |
我使用内置的那个选项还是会报错 |
|
这个报错应该是没有开启路由接管吧?直接请求了 kimi 的 response 接口,这个接口是不存在的
Rick Gao ***@***.***> 于2026年6月16日周二 16:37写道:
… *Wcdaren* left a comment (farion1231/cc-switch#3671)
<#3671 (comment)>
新版本已经支持了自定义请求头了 Kimi 可以接入了
我使用内置的那个选项还是会报错 unexpected status 404 Not Found: The requested resource
was not found, url: https://api.kimi.com/coding/v1/responses 你们会这样吗
—
Reply to this email directly, view it on GitHub
<#3671?email_source=notifications&email_token=AKW3RFGOQHRONSSTF7QZDJD5AEBODA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINZRGY2TMNBUGUY2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4716564451>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKW3RFBK4GFZZJA7FW4JCED5AEBODAVCNFSNUABGKJSXA33TNF2G64TZHMYTAMZRHEYTENZSGQ5US43TOVSTWNBVHAZDSNRTGUYDHILWAI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
已经是开启的了 , |
感谢大大 哈哈哈 终于可以使用我的kimi了 |
…ettings Polish the provider-level User-Agent override UI on the Claude and Codex forms. - Add a shared CustomUserAgentField (label + input + preset dropdown + live validation) so both forms stay in sync. - Provide curated UA presets (Claude Code / Kilo Code families that pass coding-plan UA whitelists per farion1231#3671); the first is Claude Code's real `claude-cli/x (external, cli)` format. Whitelists gate on the name prefix, not the version, so static values stay valid across upgrades. - Expose presets via a dropdown to the right of the input (z-[200] so it renders above the dialog layers) instead of inline chips. - Move the field into the existing advanced/reasoning collapsibles. - userAgent.ts mirrors the backend byte rule (reject only control chars; non-ASCII is allowed) for a non-blocking inline hint. - i18n for all four locales (zh/en/ja/zh-TW).
Summary
Fixes #3559
Related to #2890
Kimi Coding Plan (
api.kimi.com/coding/v1) enforces a strict User-Agent whitelist. Non-whitelisted agents (Codex, OpenCode, Gemini, Hermes, OpenClaw) receive HTTP 403:This PR automatically injects a whitelisted User-Agent (
claude-cli/{version}) for all requests to Kimi endpoints when the original agent is not on the whitelist.Changes
get_agent_version()inforwarder.rsto dynamically detect the local Claude Code versionclaude-cli/{version}User-Agent for Kimi Coding Plan (api.kimi.com) and Kimi Open Platform (api.moonshot.cn) endpointsclaude-cli/{version}for Claude Code (already whitelisted)Verification
Verified via curl against
https://api.kimi.com/coding/v1/chat/completions:claude-cli/2.1.161claude-code/0.1.0codex-cli/0.136.0kimi-cli/1.0Integration tested:
Checklist
cargo fmtpassescargo clippypasses