feat(model): add built-in kimi-for-coding provider - #15
Closed
yan-ad wants to merge 3 commits into
Closed
Conversation
Adds Kimi For Coding as a drop-in provider routed through the Anthropic transport (api.kimi.com/coding/v1). Users only need to add an auth.json key 'kimi-for-coding' with their sk-kimi-... key — no URL/config needed, mirroring OpenCode's setup.
Keep the Anthropic transport generic; vendor-specific headers now live in the catalog provider (kimicode declares User-Agent: KimiCLI/1.5). The Anthropic provider applies any provider-declared headers, mirroring how OpenCode whitelists the kimi-cli UA to avoid 429 rate-limit tiers.
Owner
|
Hi @yan-ad have you tested this with your kimi sub? I don't have one so I can't test. |
Contributor
Author
|
@Blankeos not yet, still waiting the whishlist approved tho. I just find the implementation inside the opencode, will test immediately if the sub succeed / approved |
Owner
Owner
|
Alright fixed the problem in 6322075 I think we can close this now. |
Owner
|
Btw I also fixed prompt caching for this... Noticed my sub burned to 20% in the 5 hr limit with Kimi k3 low w/ just 3 prompts. That was weird. I think that was definitely bad prompt caching. I fixed them here 0e10b43 I can confirm prompts are getting cached when I check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Adds Kimi For Coding as a built-in, drop-in provider. Kimi For Coding is a separate product from Moonshot's general API and speaks the Anthropic Messages protocol at
https://api.kimi.com/coding/v1. The previous 401 was caused by crabcode routing the Moonshot provider through the OpenAI-compatible path against the wrong endpoint.This change registers a static provider extension so users only need to add an auth.json key — matching OpenCode's behavior:
No provider URL or custom-provider config required. Run
/refreshmodelsafter adding the key.Details
src/model/extensions/kimicode.rs: static provider withnpm: @ai-sdk/anthropic,api: https://api.kimi.com/coding/v1, and modelskimi-for-coding,kimi-for-coding-highspeed,k3,k3-256k. Routes through the Anthropic transport (base URL normalized to.../coding,/v1/messagesappended).src/model/extensions/mod.rsPERSISTENT_EXTENSIONS.header: [("User-Agent", "KimiCLI/1.5")]so requests carry the UA Kimi whitelists (avoids the 429 seen otherwise).User-Agent handling (refactor)
The Kimi
User-Agentrequirement is not hard-coded in the generic Anthropic provider. Instead:Providergained aheaderfield (src/model/extensions/mod.rs,src/llm/client.rs).src/aisdk/providers/anthropic.rsbuilds request headers generically and applies any provider-declaredextra_headers.src/llm/client.rs(create_anthropic_provider) threads the catalog provider's declared headers into the Anthropic client.This keeps vendor-specific knowledge (the Kimi UA) entirely inside the
kimicodeextension and the generic Anthropic provider unaware of any vendor.Verification
cargo buildclean.build_anthropic_request_headers_applies_extra_headersandcreate_anthropic_provider_applies_provider_headers.🤖 Generated with Claude Code