How to Use Kimi K3 with Claude Code: Full Setup Guide

By CodeAgentSwarm · Updated November 23, 2026

Moonshot shipped Kimi K3 on July 16, 2026, and the first question everyone asked was whether they could point Claude Code at it. The answer is yes, and on October 23, 2026 the same question came back with K3.1 Pro. Moonshot ships an Anthropic-compatible endpoint, so Claude Code talks to Kimi K3 with a few environment variables and no new tool to learn. You keep the CLI you already know, your hooks, your MCP servers and your muscle memory, and you swap the model underneath. This guide covers both ways to do it, because there are two different endpoints with two different auth variables and two different model ids, and mixing them up is the most common reason people end up staring at a 401. It also covers the part most posts skip: what changes once you switch. Tool Search is better off, WebFetch may not work, and image support depends on the model and endpoint you pick. Those are real trade-offs and you should know them before you move a real project onto this. Everything below was rechecked against Moonshot's official docs in October 2026. Their models and plans change often, so treat their docs as the source of truth if something drifts.

What Kimi K3 is, and why plug it into Claude Code

Kimi K3 is the Moonshot AI model released on July 16, 2026: a 2.8 trillion parameter Mixture of Experts model with a 1,048,576 token context window, native vision and open weights. On October 23, 2026 Moonshot followed it with K3.1 Pro, a post-trained version of K3 with the same 1M window, and now calls K3 its previous-generation flagship. Everything in this guide works with both; only the model id changes.

The detail that matters most in daily use is that K3 always reasons. At launch reasoning_effort only accepted max. Moonshot has since added low and high, and K3.1 Pro offers the same three levels. Thinking cannot be turned off on K3.1 Pro: requests without it are rejected. Inside Claude Code you switch level with /effort, as Moonshot's Claude Code setup page explains.

Pay-per-token rates for K3 and K3.1 Pro are on Moonshot's official pricing page. Context caching is automatic and cache hits are billed at the cheaper cached-input price, which matters a lot for an agent that resends a big repo context on every turn.

So why run it through Claude Code instead of Moonshot's own CLI? Because Claude Code is a harness you have already configured. Your hooks, your MCP servers, your CLAUDE.md, your skills and your slash commands all keep working. Switching the model is an environment variable. Switching the harness is a weekend.

Do not confuse the model with the CLI. Kimi K3 is the model. Kimi Code CLI is Moonshot's own terminal agent, a separate product that competes with Claude Code. This guide is about running the K3 model inside Claude Code, which needs no new CLI at all.

If you do want to try Moonshot's own CLI instead, we cover it separately: how to install and use Kimi Code, what each Kimi plan actually includes, and the head to head Kimi Code vs Claude Code. You also do not have to pick one harness: CodeAgentSwarm runs Kimi Code as a first-class agent next to Claude Code, one terminal on each, on the same project.

Pick your endpoint first: subscription or pay per token

This is the step people skip, and it is the reason most setup failures happen. Moonshot runs two separate Anthropic-compatible endpoints. They have different hosts, different auth variable names and different model ids. A key from one returns a 401 on the other. Decide which one you are on before you copy any config.

Option A: the Kimi Code subscription

You pay a flat monthly fee and get a quota. The endpoint is https://api.kimi.ai/coding/ (https://api.kimi.com/coding/ for accounts in mainland China), you authenticate with ANTHROPIC_API_KEY using a key from the Kimi Code Console, and the model id is k3.1-pro, or k3.1-pro[1m] for the full 1M window (k3 and k3[1m] still work for K3). On the plans Moonshot launched in October 2026 the weekly quota is gone: a rolling 5 hour rate window and the membership's monthly total remain. Legacy plans keep the 7 day refresh. The membership page has the current rules.

Option B: the Moonshot Open Platform

You pay per token with no monthly commitment. The endpoint is https://api.moonshot.ai/anthropic, you authenticate with ANTHROPIC_AUTH_TOKEN using a key from platform.kimi.ai, and Moonshot's own Claude Code example uses kimi-k3[1m]. Flagship models unlock after a minimum $1 top-up, and your cumulative top-up sets your account tier, which decides concurrency and requests per minute. The low tiers are tight for agent work, so read the Recharge and Rate Limits page before you judge the speed.

The auth variable is different on purpose and they fight each other. The platform endpoint uses ANTHROPIC_AUTH_TOKEN, and Moonshot explicitly says to remove ANTHROPIC_API_KEY if you have one set, because the two conflict. If you have ever exported an Anthropic key in your shell profile, unset it before you test.

Setup A: Kimi K3 in Claude Code on a Kimi Code subscription

Get a key from the Kimi Code Console, then export these before launching Claude Code:

bash
export ANTHROPIC_BASE_URL=https://api.kimi.ai/coding/
export ANTHROPIC_API_KEY=your_kimi_code_key
export ANTHROPIC_MODEL="k3.1-pro[1m]"
export ANTHROPIC_DEFAULT_OPUS_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_SONNET_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_HAIKU_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_FABLE_MODEL=$ANTHROPIC_MODEL
export CLAUDE_CODE_SUBAGENT_MODEL=$ANTHROPIC_MODEL
export CLAUDE_CODE_EFFORT_LEVEL=high
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=1048576
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048576

Then run claude and type /status. The base URL it reports should be https://api.kimi.ai/coding/. If it still shows Anthropic, your exports did not reach the process, which usually means you set them in a different shell than the one that launched the CLI.

The 1M context is gated by your plan. K3.1 Pro and K3 give you 262,144 tokens on Plus (legacy Moderato) and the full 1M only on Pro (legacy Allegretto) and above. On the lower tier, drop the [1m] suffix and set both context variables to 262144. If you tell Claude Code about a window your plan does not grant, Moonshot warns you get context overflow errors; set it too small and it compacts too early.

That gating is worth understanding before you subscribe, because the 1M context is a main selling point and it is not on the entry coding tier. Moonshot renamed its plans in October 2026 (Plus and Pro replace Moderato and Allegretto for new members, and Go has no coding quota at all), so check the official membership page at checkout rather than any table in a blog post, this one included.

Setup B: Kimi K3 in Claude Code paying per token

Get a key from platform.kimi.ai, make sure no ANTHROPIC_API_KEY is set, and export this:

bash
unset ANTHROPIC_API_KEY

export ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic
export ANTHROPIC_AUTH_TOKEN=your_platform_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 CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000
export ENABLE_TOOL_SEARCH=false

The ANTHROPIC_DEFAULT_* lines matter more than they look. Claude Code picks different models for different jobs, and if you only set ANTHROPIC_MODEL it can still reach for a Haiku or Sonnet id that does not exist on Moonshot's endpoint. Pointing all of them at the same Kimi model, plus CLAUDE_CODE_SUBAGENT_MODEL for subagents, keeps every internal call working. Moonshot's own example now points the Haiku tier at kimi-k3[1m] too, since K2 models are closed to new platform accounts from October 31, 2026 and are planned for retirement by the end of December, so this setup keeps every tier on K3.

Once it runs, remember that platform limits follow your cumulative top-up, not a plan you choose. If an agent session feels broken rather than slow, check your tier on the Recharge and Rate Limits page before you blame the model.

What stops working: the honest list

An Anthropic-compatible endpoint is compatible, not identical. Some Claude Code features do not survive the switch, and it is better to know now than to debug it at midnight.

Keep Tool Search off

Tool Search is the setting to watch. Since Claude Code v2.1.304, tool search is on by default when ANTHROPIC_BASE_URL points to a gateway, so requests carry defer_loading fields and tool_reference blocks that a non-Anthropic endpoint may not accept (Claude Code MCP docs). Newer versions retry without tool search after an unrecognized 400, at the cost of an extra rejected request. Setting ENABLE_TOOL_SEARCH=false loads every MCP tool upfront and skips those failed requests. There is also an open user report on Moonshot's tracker of subscription-endpoint sessions stuck on HTTP 400 after tool_reference blocks. It is unconfirmed, but the explicit false in the setup above costs you nothing.

WebFetch errors out

Earlier versions of Moonshot's FAQ said WebFetch was not available on the Kimi endpoint and returned a "temporarily unavailable" error or no content. The current Kimi Code FAQ no longer mentions it, and we could not confirm whether the limitation still applies. Test one WebFetch call on your endpoint before you rely on it. If it fails, paste the page content into the chat or use an MCP scraping tool.

Images depend on which endpoint you chose

This one is murkier than most posts make it sound. There is an open request asking Moonshot to support image input on the subscription endpoint from third-party tools, and it names Claude Code, Roo Code and Cursor as affected. But that is a single user request with no official reply, and the real-world evidence cuts against a total block: there are documented sessions of that same endpoint decoding base64 PNG and JPEG just fine, with only webp and gif rejected. When a third-party client cannot get images through, the culprit tends to be on the client side, not the endpoint refusing images outright.

The pay-per-token platform endpoint documents vision, because K3 and K3.1 Pro are natively multimodal. Its vision guide shows base64 images and files uploaded by file id (ms:// ids). If a pasted image fails in Kimi's own tools, the FAQ says the current model lacks image input and you should switch to a vision-capable one.

If screenshots are part of how you work, test image paste with your own client on your chosen endpoint before committing. The platform endpoint has documented vision support; the subscription endpoint is where third-party image reports get murky.

Every request thinks, and you pay for it

At launch K3 only supported max reasoning effort, and cheap questions cost real money: Simon Willison's launch test spent 13,241 reasoning tokens to produce 3,417 tokens of answer. Now that low and high exist, set the level per task with /effort. Moonshot's subscription guide recommends high for K3.1 Pro and K3. For a coding agent that fires a lot of small tool calls, effort adds up in a way a raw price-per-token comparison hides.

Run Kimi K3 and Claude side by side instead of choosing

CodeAgentSwarm in List mode with agents, statuses, current activities and project shortcuts
CodeAgentSwarm List view: each session shows its agent, status and current activity. Sample tasks shown.

The honest answer to "is Kimi K3 better than Claude for my work" is that benchmarks will not tell you. Every model release comes with its own charts, and the thing that actually matters for a coding agent, reliable tool calling as a conversation gets long, rarely shows up in them. Willison made exactly that point at K3's launch.

Which means the only useful test is your own repo, your own tasks, both models, at the same time. That is awkward with one terminal, because the setup is a set of environment variables you have to keep swapping. It stops being awkward when each terminal owns its own agent and its own environment.

That is what CodeAgentSwarm does. You give one terminal the Kimi env and one terminal your normal Claude setup, point both at the same task, and watch. Every terminal gets live diffs of what its agent touched, a desktop notification when it needs you, and searchable history afterwards, so comparing two runs is reading two histories instead of trusting your memory of what happened twenty minutes ago.

If you want the wider picture, the Claude Code vs Cursor vs Codex comparison covers how the harnesses differ, and running multiple Claude Code sessions covers the parallel workflow this builds on.

Troubleshooting the setup

  • 401 Unauthorized: you are almost certainly using a key from the wrong platform. Keys from platform.kimi.ai and platform.kimi.com are completely independent, and a key from one returns 401 on the other. Same story if you mix a Kimi Code Console key with the platform endpoint.
  • /status still shows the Anthropic base URL: your exports did not reach the process. Export them in the same shell that launches the CLI, or put them in your shell profile and open a new terminal.
  • Persistent HTTP 400 that never recovers: set ENABLE_TOOL_SEARCH=false. Since Claude Code v2.1.304 tool search is on by default behind a custom ANTHROPIC_BASE_URL, and a non-Anthropic endpoint may reject its tool_reference blocks. Then start a fresh session.
  • Context gets compacted way too early or overflows: your context setting does not match what your plan grants. On Plus or legacy Moderato use 262144, not 1048576.
  • Both an API key and an auth token set: on the platform endpoint, unset ANTHROPIC_API_KEY. Moonshot documents the conflict explicitly.

FAQ

Can I use Kimi K3 with Claude Code?

Yes. Moonshot ships Anthropic-compatible endpoints, so Claude Code talks to Kimi K3 or K3.1 Pro with only environment variables and no new CLI. With a Kimi Code subscription key, set ANTHROPIC_BASE_URL to https://api.kimi.ai/coding/ (https://api.kimi.com/coding/ in mainland China) and ANTHROPIC_MODEL to k3.1-pro or k3. With a pay-per-token platform key, use https://api.moonshot.ai/anthropic and kimi-k3[1m].

Why do I get a 401 when using my Kimi key with Claude Code?

Almost always because the key and the endpoint do not match. Moonshot runs two independent platforms, and a key from platform.kimi.ai returns 401 on platform.kimi.com and the other way around. The subscription endpoint also uses ANTHROPIC_API_KEY while the pay-per-token endpoint uses ANTHROPIC_AUTH_TOKEN, and Moonshot says to unset ANTHROPIC_API_KEY on the platform endpoint because the two conflict.

Does Kimi K3 support the full 1M context in Claude Code?

Only on the right plan. K3.1 Pro and K3 give 262,144 tokens on Plus (legacy Moderato) and the full 1,048,576 tokens on Pro (legacy Allegretto) and above. Setting CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048576 on a plan that only grants 256K causes context errors, so use 262144 and the model id without [1m] on the lower tier.

What does not work when running Kimi K3 in Claude Code?

Set ENABLE_TOOL_SEARCH=false: since Claude Code v2.1.304 tool search is on by default behind a custom base URL, and a non-Anthropic endpoint may reject its tool_reference blocks. Older Moonshot FAQs said WebFetch was unavailable on the Kimi endpoint; the current FAQ no longer says so, so test it once. Image input works only with vision-capable models, and the platform endpoint documents base64 images and ms:// file ids.

Is Kimi K3 cheaper than Claude for coding?

It depends on your workload. Moonshot publishes per-token rates for K3 and K3.1 Pro on its official pricing page, and cache hits are billed at a lower price. Reasoning effort matters as much as the rate: at launch K3 only supported max effort, while K3 and K3.1 Pro now offer low, high and max. Running it in one terminal next to your normal setup for a few days tells you more than any price table.

Is Kimi K3 the same thing as Kimi Code CLI?

No. Kimi K3 is the model, and you can run it inside Claude Code as this guide describes. Kimi Code CLI is Moonshot's own terminal agent, a separate product that competes with Claude Code and has its own config, hooks and sessions. You do not need it to use K3.