← Back to Blog

How to Use Kimi K3 (Moonshot AI) with Claude Code

Jonathan PedoeemJuly 24, 20269 min read

You run Claude Code on Kimi K3 by pointing it at Moonshot's Anthropic-compatible endpoint with 3 environment variables. You set the base URL, an auth token, and the kimi-k3[1m] model, then confirm the switch with /status. The step most people botch is leaving a stray ANTHROPIC_API_KEY set, which silently overrides your token and bills Anthropic instead.

Article highlights

  • Kimi K3 speaks Anthropic's API format, so Claude Code needs no patch
  • Running Claude Code on Kimi K3 takes 3 env vars and one /status check
  • Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY
  • The model id is kimi-k3[1m], not bare kimi-k3
  • WebFetch is temporarily unavailable on the endpoint
  • Version and observe your Kimi K3 prompts in PromptLayer

What Kimi K3 is, and why point Claude Code at it

Kimi K3 is Moonshot AI's newest model, a 2.8 trillion parameter open-weight system the company shipped to go head to head with the top US labs, as covered by Tom's Hardware and VentureBeat. It carries a 1 million token context window and prices well under frontier US models.

It matters for Claude Code because Moonshot exposes an Anthropic-compatible endpoint. Claude Code is built to talk to Anthropic's API, so it can drive Kimi K3 with no code change at all. You are not patching Claude Code. You are redirecting it at a different backend and telling it which model to call.

When is the switch worth it? Reach for Kimi K3 when your real bottleneck is token cost on long, agentic coding sessions, not when you need the single highest benchmark score. The economics only pay off once you run a lot of tokens, and the 1 million token window is the part that earns its keep on large repositories.

What Claude Code needs before you start

3 things have to be in place before you touch any environment variable.

  • Claude Code installed globally. If you do not have it yet, install it with npm.
  • A Moonshot Open Platform account with credits on it. The API is paid, so an empty balance will fail your first request.
  • Terminal access, plus somewhere safe to keep an API key out of version control.
npm install -g @anthropic-ai/claude-code

Before you change anything, note your current Anthropic setup, or copy your existing config aside, so you can flip back to Claude in one step. Nobody remembers their old environment variables under deadline pressure.

Step 1: Create your Moonshot API key

Sign in to the Moonshot Open Platform console and create an API key under your default project. Add credits to the account while you are there. Treat the key like any other secret. Keep it out of git, out of committed dotfiles, and out of anything you paste into a chat window.

You will drop this key into the ANTHROPIC_AUTH_TOKEN variable in the next step, so have it on your clipboard or in a secrets manager before you move on.

Step 2: Set the environment variables for Kimi K3

This is the core of the setup. Export the following in your shell. Every model alias is set to Kimi so that whichever alias Claude Code reaches for, it routes to kimi-k3[1m].

export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="YOUR_MOONSHOT_API_KEY"
export ANTHROPIC_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_OPUS_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_SONNET_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_FABLE_MODEL="kimi-k3[1m]"
export CLAUDE_CODE_SUBAGENT_MODEL="kimi-k3[1m]"
export ENABLE_TOOL_SEARCH="false"
export CLAUDE_CODE_AUTO_COMPACT_WINDOW="1048576"
export CLAUDE_CODE_EFFORT_LEVEL="max"

3 details in that block trip up almost everyone, and they are the reason a fresh setup silently keeps calling Claude instead of Kimi K3.

Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY

Moonshot's guide authenticates through ANTHROPIC_AUTH_TOKEN. If you also have an ANTHROPIC_API_KEY set from a previous Claude Code session, it takes precedence, and Claude Code will quietly keep billing Anthropic on your old key. Unset the old key before you start. This one variable is the most common reason people think the switch failed when the config was otherwise correct.

The model id is kimi-k3[1m], not kimi-k3

On the Anthropic-compatible endpoint the model id is kimi-k3[1m], the 1 million token context variant. The bare kimi-k3 string is the id for Moonshot's OpenAI-style endpoint, a different integration path. Mixing the two is a common copy-paste error, so match the id to the endpoint you are using.

Turn tool search off

Set ENABLE_TOOL_SEARCH to false. Leaving it on causes tool-call problems against this endpoint, so the Moonshot setup for Claude Code and Kimi K3 explicitly disables it.

Step 3: Make the Kimi K3 config persistent

Shell exports die with the terminal. To keep the setup across sessions, put the same variables in the env block of your Claude Code settings file at ~/.claude/settings.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-k3[1m]",
    "ENABLE_TOOL_SEARCH": "false",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1048576",
    "CLAUDE_CODE_EFFORT_LEVEL": "max"
  }
}

2 things to know about this file. Values in the settings env block override anything you exported in the terminal, so the file wins if the two ever disagree. And it holds your key in plain text, so never commit it. Restart Claude Code after you save so it reads the new config.

Step 4: Verify the switch with /status

Start Claude Code and run the /status command. Confirm 2 lines. The base URL should read https://api.moonshot.ai/anthropic, and the model should read kimi-k3[1m]. If either still shows an Anthropic value, an old variable is winning, and the auth token trap from Step 2 is the first place to look.

Then send a trivial message such as hi, and a normal reply means the end to end path works. Do not worry that the /model menu inside Claude Code will not list Kimi. That menu holds fixed aliases only, and you do not switch anything there, so its absence is expected rather than a sign of a broken Kimi K3 setup.

Step 5: Tune thinking effort

Kimi K3 thinks by default. You control how hard it thinks with CLAUDE_CODE_EFFORT_LEVEL, which accepts low, high, or max. You can also type /effort inside a session to change the level without editing any environment variable, which is handy when one task needs deep reasoning and the next is a quick edit.

The tradeoff is direct. Higher effort means more thorough reasoning and more output tokens, and output tokens are the expensive side of the bill. Default to a lower effort for routine edits and raise it only for genuinely hard problems, rather than running everything at max out of habit.

Known limitations and gotchas with Kimi K3 in Claude Code

The setup works, but a few things behave differently from a stock Claude Code install. Knowing them up front saves an afternoon of confused debugging.

  • WebFetch is temporarily unavailable at this endpoint, per Moonshot's own Claude Code and Kimi documentation. If your workflow leans on fetching URLs mid-session, keep a Claude profile around for that step.
  • Tool search must stay disabled with ENABLE_TOOL_SEARCH set to false. This is not optional for a clean run.
  • The /model menu does not surface Kimi models. Targeting happens through the environment variables, not the picker.
  • An ANTHROPIC_API_KEY left in your environment overrides ANTHROPIC_AUTH_TOKEN. It is the single most common failure and worth checking twice.

What Kimi K3 costs to run in Claude Code

Kimi K3 prices flat across its full 1 million token context, with no length tiering. As of July 2026 the published rates on Moonshot's own pricing page are straightforward.

  • Input (cache miss): $3 per 1M tokens.
  • Input (cache hit): $0.30 per 1M tokens.
  • Output: $15 per 1M tokens.

The cache hit rate is where agentic coding actually saves money. Claude Code re-sends a lot of the same context on every turn, so a large share of your input bills at the cache rate of $0.30 rather than the full $3. That is why the effective cost of a long coding session lands well under the headline input number, and it is the practical reason cost-sensitive teams pair Kimi K3 with a harness like Claude Code that reuses context aggressively.

Managing the prompts you run against Kimi K3

Swapping the model under Claude Code changes behavior. Outputs move, tool-calling patterns shift, and edge cases that never fired on Claude can start failing on Kimi K3. A model swap is exactly the moment prompt version control and evaluation stop being optional hygiene and start being the thing that keeps your app from quietly regressing.

This is the gap PromptLayer fills. It is a prompt CMS, an eval harness, and an LLM observability layer built around the prompt as the unit of work. Before you cut over, you can evaluate the old prompt against Kimi K3 and your previous model side by side, backtest both on real production history, and version each change with a release label so a rollback is one click. After the switch, per-version tracking of cost, latency, and quality tells you whether Kimi K3 actually held up on your workload or only looked cheaper on paper.

The other reason it fits a model swap is who gets to touch the prompts. A domain expert can edit and ship a prompt version through the CMS without opening the codebase, while your engineers keep the release labels and regression tests they trust in production. If you are weighing how to manage this at all, PromptLayer's own rundown of prompt versioning tools is a fair place to see the tradeoffs before you commit.

Frequently asked questions

Does Kimi K3 work with Claude Code?

Yes. Moonshot exposes an Anthropic-compatible endpoint, so Claude Code drives Kimi K3 with no code changes. You set the base URL, an auth token, and the model through environment variables, then verify with /status.

What is the Kimi K3 model id for Claude Code?

On the Anthropic-compatible endpoint it is kimi-k3[1m], the 1 million token context variant. The bare kimi-k3 id belongs to Moonshot's OpenAI-style endpoint, which is a separate integration path.

Is Kimi K3 free to use?

No. Kimi K3 is open-weight, but calling it on Moonshot's hosted API is paid, at $3 per 1M input tokens and $15 per 1M output tokens. You could self-host the open weights, but that needs serious hardware, so most teams use the paid API.

Why does Claude Code ignore my Kimi K3 key?

Almost always because an ANTHROPIC_API_KEY is still set in your environment. It takes precedence over ANTHROPIC_AUTH_TOKEN, so Claude Code keeps using the old Anthropic key. Unset it and restart.

Does WebFetch work with Kimi K3 in Claude Code?

Not right now. Moonshot lists WebFetch as temporarily unavailable at the endpoint. Keep a separate Claude Code profile for any task that depends on fetching URLs.

Where to go next

That is the whole path. 3 environment variables, a persistent settings file, and one /status check, and Claude Code is running on Kimi K3 with a 1 million token window at a fraction of frontier pricing. Start with a small, low-stakes task, watch how it handles your codebase, and dial the effort level to match the work.

As you lean on it, keep an eye on both quality and cost across the switch. If you are shipping prompts to production, version and observe them in PromptLayer so a change in model never turns into a silent change in your product.

Related articles

Kimi K3 Claude Code setup, environment variables, model id, pricing, and current limitations.

Socials
Integrations
PromptLayer
Company
All services online
Location IconPromptLayer is located in the heart of New York City
PromptLayer © 2026