How to Use Kimi K3.1 Pro in Claude Code (2026 Setup)
The short answer
Claude Code can run Kimi K3.1 Pro by pointing its Anthropic API settings at Moonshot’s Anthropic-compatible endpoint. As of November 9, 2026, there are two routes:
- Kimi Code membership (flat plan quota) — base URL
https://api.kimi.ai/coding/, model IDsk3.1-pro,k3.1-pro[1m]ork3.1-pro-highspeed. - Kimi API pay-as-you-go (per token) — base URL
https://api.moonshot.ai/anthropic, model IDkimi-k3.1-proat $2 input / $10 output per million tokens.
Set every model variable, not just the main one, or sub-agents and background tasks fail quietly. Moonshot’s own Terminal-Bench 4.0 run of K3.1 Pro (65.7%, against 66.4% for Claude Opus 5.5) used the Claude Code harness, so this is a setup Moonshot tests against.
Which route to pick
Prices from Moonshot’s pricing page and Kimi Code docs on November 9, 2026.
| Kimi Code membership | Kimi API (pay-as-you-go) | Third-party hosts | |
|---|---|---|---|
| Base URL | https://api.kimi.ai/coding/ | https://api.moonshot.ai/anthropic | Provider-specific |
| Auth variable | ANTHROPIC_API_KEY | ANTHROPIC_AUTH_TOKEN | Provider-specific |
| K3.1 Pro model ID | k3.1-pro / k3.1-pro[1m] | kimi-k3.1-pro | e.g. OpenRouter moonshotai/kimi-k3.1-pro |
| Price | Plan quota (Go has no coding quota) | $2 in / $0.20 cache hit / $10 out; Highspeed $4 / $20; Batch 60% of standard | Together AI $2 / $0.20 / $10; OpenRouter endpoints from about $0.39 / $7.91 (FP4) |
| Context | Plus/Moderato 262,144; Pro/Allegretto+ 1,048,576 | 1,048,576 | Varies by host |
| Best for | Daily coding at a predictable monthly cost | Bursty use, automation, CI | Routing several models through one key |
Model prices across vendors are in our current API price table.
Step 1 — Clear old settings
Moonshot’s guide warns that stale values in the env block of ~/.claude/settings.json override variables exported in your shell. Remove any old ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL, the ANTHROPIC_DEFAULT_*_MODEL entries, CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_EFFORT_LEVEL and CLAUDE_CODE_AUTO_COMPACT_WINDOW, and check ~/.zshrc or ~/.bashrc for leftover ANTHROPIC_* exports.
Step 2 — Add the Kimi variables
For a Kimi Code membership with the 1M window (Pro/Allegretto and above), Kimi’s docs give:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.kimi.ai/coding/",
"ANTHROPIC_API_KEY": "<your Kimi Code key>",
"ANTHROPIC_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "k3.1-pro[1m]",
"CLAUDE_CODE_SUBAGENT_MODEL": "k3.1-pro[1m]",
"CLAUDE_CODE_EFFORT_LEVEL": "high",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1048576",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1048576"
}
}
On Plus/Moderato use k3.1-pro and 262144 for both context values. For pay-as-you-go, switch the base URL to https://api.moonshot.ai/anthropic, put the key in ANTHROPIC_AUTH_TOKEN instead of ANTHROPIC_API_KEY, and use kimi-k3.1-pro as the model ID (Moonshot’s own example still shows kimi-k3[1m], which selects the older Kimi K3 at $3 / $15). The key sits in this file in plain text, so never commit it.
Step 3 — Verify
Restart Claude Code and run /status: the base URL and model should show the Kimi values. Then send a short message. For the pay-as-you-go route, Moonshot suggests a one-token curl against /anthropic/v1/messages first; a 401 means the key does not match the platform.
Things that behave differently
- Always-on thinking. K3.1 Pro only runs with thinking enabled; requests with it disabled are rejected. Reasoning effort accepts
low,highandmax(API defaultmax). - Fixed sampling. Temperature 1.0 and top-p 0.95 are fixed; omit them.
- Missing tiers fail silently. If
ANTHROPIC_DEFAULT_HAIKU_MODEL,..._FABLE_MODELorCLAUDE_CODE_SUBAGENT_MODELis unset, Claude Code asks the Kimi endpoint for a Claude model name and those tasks error out. - Support boundary. This is Moonshot’s integration, documented by Moonshot. Claude Code’s interface and variables can change between versions, so re-check after upgrades.
Should you self-host instead?
The weights are open (Hugging Face moonshotai/Kimi-K3.1-Pro, 2.8T MoE / 104B active, MXFP4), but the vLLM recipe targets an 8-way tensor-parallel setup on two GB300 trays, one B300 node or one MI355X node. For one developer, the API or a plan is far cheaper. Hardware detail for the K3 family is in how to run Kimi K3 locally; the model itself is explained in what is Kimi K3.1 Pro.
Last verified: November 9, 2026.