What you will have at the end
By the end of this guide, Claude Code will send its requests to Moonshot AI's Kimi API instead of Anthropic, with Kimi K3 as the model for the main conversation and sub-agents. It is for developers who already like Claude Code's terminal workflow but want to run Kimi K3 on pay-as-you-go API billing. The steps follow Moonshot's own Claude Code guide, checked on October 26, 2026; AppFor.ai has not recorded its own run of this setup.
If you only want to chat with Kimi K3 or have it build slides and documents, you do not need any of this: use the Kimi app on the web or mobile. Our Kimi K3 profile covers the app plans and models.
Before you start
You need a computer running macOS, Linux or Windows, a terminal, an account on the Kimi API Platform with credit, and a Kimi API key. The Kimi API is billed per token with no subscription and is separate from Kimi membership and Kimi Code plans, so a Kimi app subscription does not pay for these calls.
At our check, kimi-k3 cost $3 per million input tokens and $15 per million output tokens, with cached input at $0.30. Kimi K3.1 Pro cost $2 and $10, and K3.1 Pro Highspeed $4 and $20. K3.1 Pro is the cheaper of the two per token; Moonshot's Claude Code example uses kimi-k3, so check the exact K3.1 Pro model ID in Kimi's model list before you swap it into every variable. Long agent sessions resend a lot of context, so set a spending limit or top up a small amount first.
- Claude Code, installed with Anthropic's native installer or npm (Node.js 22 or later for npm)
- A Kimi API key from the Kimi API Platform
- Write access to ~/.claude/settings.json
- A small test repository you do not mind the agent editing
1. Install Claude Code or clean up an old setup
If Claude Code is not installed, use Anthropic's native installer: on macOS and Linux run curl -fsSL https://claude.ai/install.sh | bash, on Windows PowerShell run irm https://claude.ai/install.ps1 | iex. Moonshot's guide also documents a global npm install, which needs Node.js 22 or later.
If you have used Claude Code with another provider before, check the env field of ~/.claude/settings.json and your ~/.zshrc or ~/.bashrc for old ANTHROPIC_* values. Moonshot warns that stale values in settings.json override what you export in the terminal and can silently send requests to the wrong model.
Checkpoint: running claude --version in a new terminal prints a version number, and settings.json has no leftover provider values.
2. Create a Kimi API key and test it with curl
Create an API key in the Kimi API Platform. Before touching Claude Code, send one tiny request to Kimi's Anthropic-compatible endpoint so you know the key works. The request below asks for a single output token, so it costs almost nothing.
3. Point every Claude Code model tier at Kimi
Claude Code uses different model tiers for the main conversation, background tasks such as titles and summaries, and sub-agents. Moonshot's documentation says that configuring only some of them makes the others fail silently, so set all of them. Put the following in the env field of ~/.claude/settings.json and restart Claude Code.
Moonshot's example sets the Haiku tier to kimi-k2.7-code. Its pricing page says K2 series models will not be available to accounts registered from October 31, 2026 and will be retired by the end of December 2026. If your account is new, the snippet below uses kimi-k3[1m] for every tier instead; that is our adaptation, not Moonshot's example. The settings file stores your key in plain text, so never commit it to git.
4. Confirm Claude Code is really using Kimi
Start Claude Code in your test repository and enter /status. According to Moonshot, the base URL should show https://api.moonshot.ai/anthropic and the model kimi-k3[1m]. The /model menu should list the models you configured. Then send a short message such as hello and wait for a normal reply.
Moonshot notes that kimi-k3 has thinking on by default and works without extra configuration. If you previously signed in with /login, the auth token takes precedence; /status shows the active credential source and /logout clears the saved login.
Checkpoint: /status shows the Moonshot base URL, and the request appears in your usage on the Kimi API Platform.
5. Run a first real task: fix one failing test
Suggested example, not a recorded AppFor.ai run: pick a small repository with one failing test whose cause you already know. Use a prompt that asks the agent to explain before it edits, so you can judge its reasoning without trusting a green test alone.
6. Check the result before you keep it
Accept the change only if all of these hold. If one fails, reply with the specific problem, for example only touch src/dates.py, and ask for a new diff rather than starting over.
- The explanation names the same cause you already know
- The diff touches only the files needed for the fix
- The test file passes when you run it yourself, not only in the agent's output
- No new dependencies, config changes or deleted tests appear in git diff
- Your Kimi usage for the session matches what you expected to spend
Common problems and fixes
401 errors: the key is wrong, or it belongs to Kimi Code rather than the Kimi API Platform. Kimi Code uses a different base URL (api.kimi.ai/coding/ outside China) and the ANTHROPIC_API_KEY variable, so do not mix the two setups.
Model not found: check the spelling of every model variable, kimi-k3[1m], with no extra spaces or quotes.
Background task or sub-agent errors: the Haiku, Fable or sub-agent variable is missing, so Claude Code asks for a model name the Kimi endpoint does not know. Fill in every tier.
Changes do not take effect: remove stale values from settings.json and shell files, then restart Claude Code.
Context errors or early compaction: CLAUDE_CODE_AUTO_COMPACT_WINDOW must match the model's context window. Moonshot's example uses 1000000 for kimi-k3[1m].
If you need Claude-specific features or Anthropic models, switch back by removing the Kimi variables from settings.json and restarting Claude Code.
Go to the source
Sources & further reading
Based on the official documentation below. Features and access can change; check the provider before making a decision.
Was this page useful?
Help us make our coverage more useful. This is feedback on the page, not a rating of the tool.
Go a little further