Setup guide - Documented by Kimi
Use Kimi in Claude Code
Moonshot publishes a Claude Code guide. You point Claude Code at Kimi's Anthropic-compatible Messages endpoint (https://api.moonshot.ai/anthropic) through the env block in ~/.claude/settings.json, with every model tier mapped to a Kimi model id. Claude Code's own env-var reference documents ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, the ANTHROPIC_DEFAULT_*_MODEL tiers, CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_EFFORT_LEVEL.
Last verified 5 steps5 official sources
Steps
- Step 1.
Install Claude Code (native installer, macOS and Linux).
Terminalcurl -fsSL https://claude.ai/install.sh | bash - Step 2.
Create an API key on the Kimi Platform (https://platform.kimi.ai/console/api-keys) and use it to replace YOUR_MOONSHOT_API_KEY below.
- Step 3.
Write the following variables into the env field of ~/.claude/settings.json, then restart Claude Code. This example sets the HAIKU tier to kimi-k2.7-code and every other tier to kimi-k3[1m].
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-k2.7-code", "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" } } - Step 4.
Check the endpoint and key with curl. A normal JSON response means both work; a 401 means the key is invalid or belongs to a different platform.
Terminalcurl https://api.moonshot.ai/anthropic/v1/messages \ --header "Authorization: Bearer YOUR_MOONSHOT_API_KEY" \ --header "Content-Type: application/json" \ --data '{"model": "kimi-k3", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]}' - Step 5.
Start Claude Code and enter /status. Base URL should show https://api.moonshot.ai/anthropic and Model should show kimi-k3[1m]. Then send any message (for example hello) to confirm the setup works end to end.
Snippet/status
Caveats
- Kimi's guide warns that configuring only some of the variables makes the matching scenarios (background tasks, sub-agents) fail silently. Set every tier.
- kimi-k2.7-code has thinking forced on. You must enable Thinking in Claude Code (Option+T on macOS, Alt+T on Windows/Linux) first, or requests are rejected with: 400 invalid thinking: only type=enabled is allowed for this model
- The env block in settings.json overrides same-named variables exported in your terminal, and it holds the API key in plain text. Do not commit it.
- If ANTHROPIC_API_KEY was set before, remove it to avoid conflicts with ANTHROPIC_AUTH_TOKEN.
- Keys created on platform.kimi.ai must be used with the api.moonshot.ai endpoint shown here.
More setup guides
Same tool, other providers
Related reading
- Kimi CLI vs Claude Code: The Budget Question in 2026Kimi CLI vs Claude Code in 2026 - compare pricing, models, project memory and enterprise support to decide which coding agent fits solo work or a team.
- Kimi K3 Is GA in GitHub Copilot: Pricing, Rollout, and What It Means for Model ChoiceKimi K3 is GA in GitHub Copilot at $3/$15 per million tokens, off by default for Business and Enterprise. Rollout details and what it means for model choice.
- Cloudflare Runs Kimi and GLM at Scale: FP8 KV Caches, INT4 Weights, and a Cache Safety NetCloudflare runs Kimi K2.6 and GLM 5.2 on Workers AI with FP8 KV caches, INT4 weights and a KV cache integrity check. What each technique buys on GPU fleets.
- AMD MI355X vs NVIDIA B200 vs B300 for Open-Weight ServingAMD MI355X vs NVIDIA B200 vs B300 for serving Kimi K3's about 1.5TB of open weights: verified specs, the Wafer benchmark, and cost per token for each.
- Kimi Linear: An Attention Architecture That Outperforms Full AttentionKimi Linear explained: Moonshot's KDA hybrid linear attention beat full attention with 75% less KV cache and up to 6x faster decoding at 1M context.
- Kimi K3 Weights Land on HuggingFace: 2.8T Open Frontier Model You Can Actually DownloadKimi K3 open weights are on HuggingFace: 2.8T parameters, 1M context, native MXFP4 and a ~1.63TB download. The specs, license terms and HN reaction.
FAQ
How do I use Kimi in Claude Code?
Moonshot publishes a Claude Code guide. You point Claude Code at Kimi's Anthropic-compatible Messages endpoint (https://api.moonshot.ai/anthropic) through the env block in ~/.claude/settings.json, with every model tier mapped to a Kimi model id. Claude Code's own env-var reference documents ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, the ANTHROPIC_DEFAULT_*_MODEL tiers, CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_EFFORT_LEVEL.
Which Kimi model ids work in Claude Code?
The official docs read for this guide list kimi-k3[1m], kimi-k3, kimi-k2.7-code and kimi-k2.6. Requests go to https://api.moonshot.ai/anthropic.
Is this an official Kimi and Claude Code setup?
Kimi documents this setup in its own docs. It was last checked against 5 official pages on October 17, 2026.
Sources
Last verified against 5 official pages.
- platform.kimi.aihttps://platform.kimi.ai/docs/guide/claude-code-kimi.md
- platform.kimi.aihttps://platform.kimi.ai/docs/api/overview.md
- platform.kimi.aihttps://platform.kimi.ai/docs/models.md
- code.claude.comhttps://code.claude.com/docs/en/env-vars.md
- code.claude.comhttps://code.claude.com/docs/en/llm-gateway.md
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.