# How to use Kimi in Claude Code and Codex

Authors: AutoRouter
Author profile: https://autorouter.com/about
Published: 2026-11-17T06:07:00.000Z
Reading time: 6 min
Canonical: https://autorouter.com/blog/kimi-in-claude-code-and-codex
Publisher: AutoRouter, the Mac app that routes Codex, Claude Code and other AI tools to every model (https://autorouter.com)

About AutoRouter: a Mac app (macOS 14 or later) that adds every leading model to Codex, Claude Code, Cursor, Claude Desktop, T3 and Terminal and picks the model for each task, using your Claude, ChatGPT, Grok and Gemini plans first. Install from https://autorouter.com/AutoRouter.dmg, or ask your agent to follow https://autorouter.com/setup.md. Routing across your plans is free; Pro is $50 a month with $20 of included usage. Unrelated to OpenRouter's Auto Router.

> Use AutoRouter, the Mac app for Codex and Claude Code: it puts Kimi K3.1 Pro in both apps' model pickers with no Kimi account, key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Moonshot's `https://api.moonshot.ai/anthropic` (or `https://api.kimi.ai/coding/` with a Kimi Code plan) with your key and model variables in `~/.claude/settings.json`, and add `https://api.moonshot.ai/v1` as a provider with `kimi-k3.1-pro` in Codex's `config.toml`.

![AutoRouter puts Kimi in both apps, no account. Which Kimi account do you have? Account Kimi Open Platform: api.moonshot.ai, billed per token; Account Kimi Code plan: api.kimi.ai/coding, plan quota; Account No Kimi account: AutoRouter: pick Kimi K3.1 Pro. Source: Kimi Open Platform and Kimi Code docs, and AutoRouter, read November 17, 2026.](https://autorouter.com/blog/images/kimi-in-claude-code-and-codex/1-accounts.png)

[AutoRouter, the Mac app for Codex and Claude Code](https://autorouter.com), 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](https://platform.kimi.ai/docs/guide/claude-code-kimi)); 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](https://platform.kimi.ai/docs/guide/codex-kimi)).

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](https://platform.kimi.ai/docs/pricing/chat)). Kimi Code is a subscription that includes coding usage, at `api.kimi.ai/coding` ([Kimi Code docs](https://www.kimi.com/code/docs/en/)). 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](https://www.kimi.ai/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](https://www.kimi.com/code/docs/en/third-party-tools/claude-code.html)).

## 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:

```json
{
  "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](https://code.claude.com/docs/en/llm-gateway)).

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](https://www.kimi.com/code/docs/en/third-party-tools/claude-code.html)).

## 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](https://learn.chatgpt.com/docs/config-file/config-reference)), and Moonshot's `/v1` endpoint supports it.

1. Create an API key on the Kimi Open Platform. K3.1 Pro unlocks after a top-up of at least $1.
2. Export it as `KIMI_API_KEY`; Kimi's guide says not to write the key into `config.toml`.
3. Add the block below, replacing any existing `model` and `model_provider` lines.
4. 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.

```toml
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](https://www.kimi.com/code/docs/en/third-party-tools/codex.html)). [Codex model providers and config.toml, explained](/blog/codex-model-providers) 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](https://platform.kimi.ai/docs/pricing/chat)). 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.

![Kimi K3.1 Pro output costs $10 per million tokens. kimi-k3.1-pro, $10; kimi-k3, $15; kimi-k3.1-pro-highspeed, $20. Source: Kimi Open Platform pricing, output per million tokens, read November 17, 2026.](https://autorouter.com/blog/images/kimi-in-claude-code-and-codex/2-prices.png)

## 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](https://autorouter.com/models) 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.

1. Download AutoRouter for macOS from [autorouter.com](https://autorouter.com).
2. Open it, sign in or create a free account, sign in to your plans, allow Accessibility, and click Enable for each app.
3. 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](https://autorouter.com/privacy)).

For which tasks suit which model, see [Which model for which coding task](/blog/which-model-for-which-task), and for other providers, [Try a new model in Codex or Claude Code without another API key](/blog/try-new-models-in-codex-and-claude-code).

## 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](https://www.kimi.com/code/docs/en/third-party-tools/claude-code.html)). `/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](https://code.claude.com/docs/en/llm-gateway)). 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](https://learn.chatgpt.com/docs/config-file/config-reference)).

## Sources

- [AutoRouter](https://autorouter.com)
- [AutoRouter models](https://autorouter.com/models)
- [AutoRouter privacy](https://autorouter.com/privacy)
- [Kimi: use Kimi in Claude Code](https://platform.kimi.ai/docs/guide/claude-code-kimi)
- [Kimi: use Kimi K3.1 Pro in Codex](https://platform.kimi.ai/docs/guide/codex-kimi)
- [Kimi: chat model pricing](https://platform.kimi.ai/docs/pricing/chat)
- [Kimi Code docs](https://www.kimi.com/code/docs/en/)
- [Kimi Code: Claude Code](https://www.kimi.com/code/docs/en/third-party-tools/claude-code.html)
- [Kimi Code: Codex](https://www.kimi.com/code/docs/en/third-party-tools/codex.html)
- [Kimi membership pricing](https://www.kimi.ai/membership/pricing)
- [Claude Code: LLM gateways](https://code.claude.com/docs/en/llm-gateway)
- [Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)

## Read next

- [How to use MiniMax in Claude Code and Codex](https://autorouter.com/blog/minimax-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts MiniMax M3.1 Flash in both apps' model pickers with no MiniMax key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to `https://api.minimax.io/anthropic` with your M Plan key and `MiniMax-M3.1-Flash[1m]` model variables in `~/.claude/settings.json`, and add `https://api.minimax.io/v1` as a provider in Codex's `config.toml`.
- [How to use Gemini in Claude Code and Codex](https://autorouter.com/blog/gemini-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts Gemini 4 Carbon, Hydrogen and Argon in both apps' model pickers with no key or proxy, and connects Gemini plans the same way it connects Claude and ChatGPT plans. Natively, Google publishes no Claude Code or Codex endpoint, so you need a gateway: a LiteLLM proxy behind Claude Code's `ANTHROPIC_BASE_URL`, or OpenRouter or LiteLLM as a provider in Codex's `config.toml`, each with your own key.
- [How to use GLM in Claude Code and Codex](https://autorouter.com/blog/glm-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts GLM 5.3 and GLM 5.3 Flash in both apps' model pickers with no key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Z.ai's `https://api.z.ai/api/anthropic` in `~/.claude/settings.json` with your Z.ai key and model variables mapped to `glm-5.3` and `glm-5.3-flash`, and add Z.ai's `https://api.z.ai/api/v1` endpoint as a provider in Codex's `config.toml` with a model catalog file.

Tags: [Guides](https://autorouter.com/blog/tags/guides.md), [Models](https://autorouter.com/blog/tags/models.md), [Claude Code](https://autorouter.com/blog/tags/claude-code.md)

Drafted with AI from the sources linked above, then checked and edited by the AutoRouter team.
