How to use Kimi in Claude Code and Codex
AutoRouter6 min read
AutoRouter, the Mac app for Codex and Claude Code, puts Kimi K3.1 Pro in both apps' model pickers with no Kimi account, key or config. The native route takes a Kimi key and config in each app. To use Kimi in Claude Code, add Moonshot's Anthropic-compatible endpoint, https://api.moonshot.ai/anthropic, your Kimi Open Platform key and the model variables to the env block of ~/.claude/settings.json (Kimi's Claude Code guide); with a Kimi Code subscription, the endpoint is https://api.kimi.ai/coding/ instead. In Codex, add https://api.moonshot.ai/v1 as a provider and set model = "kimi-k3.1-pro" in ~/.codex/config.toml (Kimi's Codex guide).
AutoRouter wrote this post. The Kimi routes below bill to your Kimi balance or plan with nothing in between. Every setting is copied from Moonshot's, Anthropic's or OpenAI's docs as checked on November 17, 2026; check the linked page before you paste.
Which Kimi account do you need?
Moonshot sells Kimi two ways, and each has its own keys and endpoints. The Kimi Open Platform is pay as you go, with no subscription, at api.moonshot.ai (Kimi pricing). Kimi Code is a subscription that includes coding usage, at api.kimi.ai/coding (Kimi Code docs). A key from one doesn't work at the other's endpoint.
| Account | Endpoint for Claude Code | Endpoint for Codex | What pays |
|---|---|---|---|
| Kimi Open Platform | https://api.moonshot.ai/anthropic | https://api.moonshot.ai/v1 | Your balance, per token |
| Kimi Code (Plus and up) | https://api.kimi.ai/coding/ | https://api.kimi.ai/coding/v1 | Your plan's coding quota |
| AutoRouter (Mac) | None to set | None to set | Pro usage at the provider's price plus 10% |
Kimi Code's pricing page lists Plus at $19, Pro at $39 and Max at $99 a month on monthly billing, as of November 17, 2026 (Kimi membership pricing). Plus gets k3.1-pro with a 262,144-token context; Pro and above get k3.1-pro and k3.1-pro-highspeed with 1,048,576 tokens (Kimi Code: Claude Code).
How do you use Kimi in Claude Code?
Put the endpoint, key and every model tier in the env block of ~/.claude/settings.json, then restart Claude Code. Kimi's guide warns that setting only some of the model variables makes the matching tasks fail silently, and that the env block overrides exports in your shell. With an Open Platform key:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.moonshot.ai/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_MOONSHOT_API_KEY",
"ANTHROPIC_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "kimi-k3[1m]",
"CLAUDE_CODE_SUBAGENT_MODEL": "kimi-k3[1m]",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"CLAUDE_CODE_EFFORT_LEVEL": "max"
}
}
That page's block sets kimi-k3, while its own test request and its Codex guide use kimi-k3.1-pro, the newer model. Run /status afterwards: the base URL should read https://api.moonshot.ai/anthropic. While the token is set, it replaces your claude.ai login, so your Claude plan's limits don't apply (Anthropic docs).
With a Kimi Code plan, the block uses https://api.kimi.ai/coding/ and ANTHROPIC_API_KEY in place of ANTHROPIC_AUTH_TOKEN, sets every model to k3.1-pro, and caps the context at 262,144 tokens (k3.1-pro[1m] and 1,048,576 on Pro and above). Kimi Code's page also has a short script to run once before launch (Kimi Code: Claude Code).
How do you use Kimi in Codex?
Add Moonshot as a provider in ~/.codex/config.toml. Codex speaks only the Responses API (OpenAI config reference), and Moonshot's /v1 endpoint supports it.
- Create an API key on the Kimi Open Platform. K3.1 Pro unlocks after a top-up of at least $1.
- Export it as
KIMI_API_KEY; Kimi's guide says not to write the key intoconfig.toml. - Add the block below, replacing any existing
modelandmodel_providerlines. - Restart Codex. The Codex app may show the model as Custom, and a "Model metadata for kimi-k3.1-pro not found" warning is expected.
model = "kimi-k3.1-pro"
model_provider = "kimi"
model_context_window = 1048576
[model_providers.kimi]
name = "Kimi"
base_url = "https://api.moonshot.ai/v1"
env_key = "KIMI_API_KEY"
wire_api = "responses"
If you get a 404, check that base_url ends in /v1. The Codex app opened from the Dock doesn't read your shell profile; Kimi Code's Codex guide sets the key with launchctl setenv KIMI_API_KEY and a full restart, which lasts until you log out (Kimi Code: Codex). Codex model providers and config.toml, explained covers profiles and the other provider keys.
What does Kimi K3.1 Pro cost through the API?
On the Kimi Open Platform, kimi-k3.1-pro costs $2.00 per million input tokens, $0.20 per million cached input tokens and $10.00 per million output tokens, as of November 17, 2026 (Kimi pricing). That is less than kimi-k3 at $3.00 and $15.00, and half of kimi-k3.1-pro-highspeed at $4.00 and $20.00. The K3 models have a 1,048,576-token context window.
How do you use Kimi with AutoRouter?
Pick Kimi K3.1 Pro in the model picker. AutoRouter adds 20+ frontier and open-weight models to Codex and Claude Code with no keys or endpoints to set up, and AutoRouter's models page lists Kimi K3.1 Pro for open-weight reasoning and coding across long supplied documents, as of November 17, 2026. Choosing it sends your requests straight to it. Choosing AutoRouter lets it work out how hard each task is and send each one to the model that fits.
- Download AutoRouter for macOS from autorouter.com.
- Open it, sign in or create a free account, sign in to your plans, allow Accessibility, and click Enable for each app.
- Start a new session and choose a model: in Codex, from the model menu under the message box; in Claude Code, with
/model.
AutoRouter pools the plans you already pay for: Claude, ChatGPT, Grok and Gemini plans connect, any of them can run in either app, and when one account reaches its limit AutoRouter moves on to the account with the most room left before it spends any credit. Kimi is a pay-per-use model on Pro, at $50 a month with $20 of included usage each month, billed at the provider's price plus 10%. New accounts get Pro free for their first month, or until $20 of usage is spent, whichever comes first.
If Kimi is the only model you want, Moonshot's own routes cost less per token, and a Kimi Code plan gives a fixed monthly quota. AutoRouter runs on macOS 14 or later, and Claude Code needs Node 22.18 or later to use it. Requests pass through AutoRouter's servers; it doesn't store transcripts, but keeps the message that opens each request, up to 4,000 characters, to review routing (AutoRouter privacy).
For which tasks suit which model, see Which model for which coding task, and for other providers, Try a new model in Codex or Claude Code without another API key.
Questions
Why does Kimi answer with a different model than I set?
Check the model ID for typos. Kimi Code's docs say a mistyped ID silently falls back to K2.8 Preview without thinking (Kimi Code: Claude Code). /status in Claude Code shows the model it is sending.
Can I turn off thinking on Kimi K3.1 Pro?
No. Kimi Code's docs say a request that disables thinking on K3.1 Pro returns a 400 error, and Kimi's Claude Code guide says K3 always reasons. Lower CLAUDE_CODE_EFFORT_LEVEL instead.
Does my Claude plan pay for Kimi in Claude Code?
No. With a Kimi key set, Claude Code sends it in place of your claude.ai login, and the requests bill to your Kimi account (Anthropic docs). Remove the keys from the env block to go back to your plan.
How do I switch Codex back to my ChatGPT plan?
Delete the model, model_provider and model_context_window lines you added, or restore your earlier values, and restart Codex. Without model_provider, Codex uses its built-in openai provider (OpenAI config reference).