How to Use Kimi K3 in Claude Code (Official Kimi Setup, 2026)
Run Claude Code on Kimi K3 through Moonshot's official Anthropic-compatible endpoint. Exact settings.json, what every variable does, what changes, and a worked monthly cost comparison against Claude Opus 5.5 and Sonnet 5.5.
Moonshot AI documents how to run Claude Code on Kimi K3 through its Anthropic-compatible Messages API. You keep Claude Code’s interface and pay Kimi’s token prices.
Everything below follows Kimi’s official guide, Use Kimi in Claude Code, checked on 2026-11-16. Prices come from Kimi’s pricing page and Anthropic’s pricing page as recorded in DevTk.AI’s model data.
Who supports this: Moonshot documents and supports this setup. Anthropic’s Claude Code docs say Anthropic doesn’t support routing Claude Code to non-Claude models, so take problems to Kimi’s docs.
Quick answer
| Setting | Value |
|---|---|
| Endpoint (global platform keys) | https://api.moonshot.ai/anthropic |
| Endpoint (China platform keys) | https://api.moonshot.cn/anthropic, per Kimi’s Chinese guide |
| Key variable | ANTHROPIC_AUTH_TOKEN |
| Model for every tier | kimi-k3[1m] |
| Where to put it | the env block of ~/.claude/settings.json |
| Billing | Your Kimi API balance; your Claude plan is not used |
The key must come from the same platform as the endpoint. A global-platform key on the China endpoint (or the reverse) returns 401.
Step 1: install Claude Code
Kimi’s guide uses Anthropic’s native installer:
# macOS and Linux
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
Or with npm (Node.js 22 or later): npm install -g @anthropic-ai/claude-code.
If you have configured Claude Code for another provider before, clear the old values first. Leftover ANTHROPIC_* keys in the env block of ~/.claude/settings.json override what you export in the terminal, and so do stale exports in ~/.zshrc or ~/.bashrc. Kimi’s guide includes a small Node.js cleanup script that removes only the endpoint, credential and model keys.
Step 2: get a Kimi API key
Create one on the Kimi Platform.
Step 3: configure settings.json
Add this to the env block of ~/.claude/settings.json, then restart Claude Code:
{
"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"
}
}
The file now holds your API key in plain text. Don’t commit it.
Kimi’s guide stresses setting every tier. Claude Code uses different tiers for the main conversation, background summaries and subagents, and a missing one fails quietly:
| Variable | Purpose | If missing |
|---|---|---|
ANTHROPIC_BASE_URL | Kimi endpoint | Requests go to Anthropic and fail authentication |
ANTHROPIC_AUTH_TOKEN | Kimi API key | 401 errors |
ANTHROPIC_MODEL | Main conversation model | Model-not-found errors |
ANTHROPIC_DEFAULT_OPUS/SONNET/HAIKU/FABLE_MODEL | Model behind each alias | Tasks on that tier fail |
CLAUDE_CODE_SUBAGENT_MODEL | Subagent model | Subagents fail or degrade |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | When auto-compaction starts | Too small loses context early; too large causes context-length errors |
CLAUDE_CODE_EFFORT_LEVEL | Reasoning effort | Kimi recommends max |
Step 4: check it works
Test the key and endpoint directly:
curl https://api.moonshot.ai/anthropic/v1/messages \
--header "Authorization: Bearer $MOONSHOT_API_KEY" \
--header "Content-Type: application/json" \
--data '{"model": "kimi-k3.1-pro", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]}'
A JSON response means the key works; 401 means a wrong key or a platform mismatch. Then start claude and run /status: the base URL should be https://api.moonshot.ai/anthropic and the model kimi-k3[1m]. ANTHROPIC_AUTH_TOKEN takes precedence over a saved /login; run /logout if you want to clear the saved login.
What changes on Kimi K3
| Area | What happens |
|---|---|
| Your Claude plan | Requests carry the Kimi key, so Pro/Max/Ultra limits aren’t used and all tokens bill to Kimi. |
| Thinking | K3 always reasons and enables Preserved Thinking. Effort is set with CLAUDE_CODE_EFFORT_LEVEL. |
| Context | K3 has a 1,048,576-token context window, hence [1m] and the 1M auto-compact window. |
| One model everywhere | Kimi’s example uses K3 for every tier, including Haiku-tier background work. There is no cheaper “small” tier in this setup. |
Cost: Kimi K3 vs Claude Code’s default model
Claude Code defaults to Claude Opus 5.5 on paid plans and the API, per Anthropic’s model configuration docs. Subscriptions don’t publish token allowances, so this is an API-to-API comparison.
Assumed workload: 100M input tokens and 2M output tokens a month, 90% of input as cache hits (90M cached, 10M uncached). Kimi K3 charges cache writes at $3/M for the default 5-minute TTL, the same as its input price, so the uncached row already covers them. Anthropic’s cache-write premium is left out.
| Model | Uncached input | Cached input | Output | Monthly total |
|---|---|---|---|---|
| Claude Opus 5.5 | 10M × $4.00 = $40.00 | 90M × $0.20 = $18.00 | 2M × $20.00 = $40.00 | $98.00 |
| Kimi K3 | 10M × $3.00 = $30.00 | 90M × $0.30 = $27.00 | 2M × $15.00 = $30.00 | $87.00 |
| Kimi K3.1 Pro | 10M × $2.00 = $20.00 | 90M × $0.20 = $18.00 | 2M × $10.00 = $20.00 | $58.00 |
| Claude Sonnet 5.5 | 10M × $2.00 = $20.00 | 90M × $0.10 = $9.00 | 2M × $10.00 = $20.00 | $49.00 |
The honest read: on a cache-heavy workload, Kimi K3 saves about 11% against Opus 5.5 ($87 vs $98), and it costs more than Sonnet 5.5, which is cheaper on every rate (Sonnet’s cache reads cost a third of K3’s). Kimi K3 is a reason to switch if you prefer the model, not mainly to save money. For a bigger saving in Claude Code, see the DeepSeek or GLM-5.3 setups.
Kimi’s newer K3.1 Pro is cheaper than K3, and Kimi’s own verification command above calls kimi-k3.1-pro on the same endpoint. Kimi’s Claude Code guide only documents kimi-k3[1m], though, so test K3.1 Pro on a small task before you rely on it.
Troubleshooting
| Symptom | Fix |
|---|---|
| 401 errors | Check the key, check it matches the endpoint’s platform, and remove any ANTHROPIC_API_KEY |
| Model not found | Check the spelling of kimi-k3[1m] in every variable, without extra spaces or quotes |
| Subagent or background errors | Set the Haiku, Fable and subagent variables too |
| Changes don’t apply | Remove stale values from settings.json and shell profiles, then restart Claude Code |