DevTk.AI
Kimi K3Claude CodeMoonshot AIAI Coding AgentKimi API

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.

By Published 6 min read

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

SettingValue
Endpoint (global platform keys)https://api.moonshot.ai/anthropic
Endpoint (China platform keys)https://api.moonshot.cn/anthropic, per Kimi’s Chinese guide
Key variableANTHROPIC_AUTH_TOKEN
Model for every tierkimi-k3[1m]
Where to put itthe env block of ~/.claude/settings.json
BillingYour 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:

VariablePurposeIf missing
ANTHROPIC_BASE_URLKimi endpointRequests go to Anthropic and fail authentication
ANTHROPIC_AUTH_TOKENKimi API key401 errors
ANTHROPIC_MODELMain conversation modelModel-not-found errors
ANTHROPIC_DEFAULT_OPUS/SONNET/HAIKU/FABLE_MODELModel behind each aliasTasks on that tier fail
CLAUDE_CODE_SUBAGENT_MODELSubagent modelSubagents fail or degrade
CLAUDE_CODE_AUTO_COMPACT_WINDOWWhen auto-compaction startsToo small loses context early; too large causes context-length errors
CLAUDE_CODE_EFFORT_LEVELReasoning effortKimi 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

AreaWhat happens
Your Claude planRequests carry the Kimi key, so Pro/Max/Ultra limits aren’t used and all tokens bill to Kimi.
ThinkingK3 always reasons and enables Preserved Thinking. Effort is set with CLAUDE_CODE_EFFORT_LEVEL.
ContextK3 has a 1,048,576-token context window, hence [1m] and the 1M auto-compact window.
One model everywhereKimi’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.

ModelUncached inputCached inputOutputMonthly total
Claude Opus 5.510M × $4.00 = $40.0090M × $0.20 = $18.002M × $20.00 = $40.00$98.00
Kimi K310M × $3.00 = $30.0090M × $0.30 = $27.002M × $15.00 = $30.00$87.00
Kimi K3.1 Pro10M × $2.00 = $20.0090M × $0.20 = $18.002M × $10.00 = $20.00$58.00
Claude Sonnet 5.510M × $2.00 = $20.0090M × $0.10 = $9.002M × $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

SymptomFix
401 errorsCheck the key, check it matches the endpoint’s platform, and remove any ANTHROPIC_API_KEY
Model not foundCheck the spelling of kimi-k3[1m] in every variable, without extra spaces or quotes
Subagent or background errorsSet the Haiku, Fable and subagent variables too
Changes don’t applyRemove stale values from settings.json and shell profiles, then restart Claude Code

Next step

Related Posts