Short version: Kimi K3 exposes an Anthropic-compatible API, so the official Claude Code CLI drives it with three environment variables and no plugin. Below is the copy-paste setup, the one leftover variable that silently breaks it, and a two-alias pattern that flips you back to Sonnet 5 the moment Kimi's launch-week capacity crunch rate-limits you. Total time: about five minutes.

Why this works at all#

You don't need a fork, a proxy, or a wrapper. Moonshot publishes a dedicated /anthropic base path that speaks the same wire protocol Claude Code already talks, so pointing the CLI at it is purely a matter of three env vars. This is the same escape hatch that makes Kimi Code the cheap challenger to Claude Code and Codex: an open-weight backend you can drive from the tools you already use.

1. Get a Moonshot API key#

Create a key in the Moonshot platform console and copy it. K3's API bills at $3 per 1M input tokens ($0.30 on a cache hit) and $15 per 1M output — roughly 40% under Opus 4.8.

2. Set the three variables#

That's the entire configuration:

export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-your-moonshot-key"
export ANTHROPIC_MODEL="kimi-k3"

claude

Launch claude in the same shell and it now routes every request to K3.

3. The one variable that silently breaks it#

If Claude Code ignores your settings and keeps talking to Anthropic — or errors on auth — the culprit is almost always a leftover ANTHROPIC_API_KEY sitting in your shell profile from an earlier setup. It silently overrides ANTHROPIC_AUTH_TOKEN. Clear it:

unset ANTHROPIC_API_KEY

Then verify. Here's the trap: the in-app /model menu never lists Kimi, so there's no menu entry to select and nothing to confirm you succeeded. Use /status instead — it prints the active base URL and model:

/status
# → Base URL: https://api.moonshot.ai/anthropic
# → Model: kimi-k3

If /status shows your Moonshot base URL and kimi-k3, the swap took.

4. Keep Sonnet 5 one word away#

Here's the part most setup guides skip, and it's the one that matters this week. Moonshot paused new subscriptions on July 18 when K3 launch demand "pushed close to the limits of our current capacity," reopening slots in batches. Translation: a mid-task rate-limit is a live risk right now. Don't let it block your afternoon — make the fallback a single word.

Add two aliases to your shell profile:

# ~/.zshrc or ~/.bashrc

# Kimi K3 profile
alias kc-kimi='ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic" \
  ANTHROPIC_AUTH_TOKEN="sk-your-moonshot-key" \
  ANTHROPIC_MODEL="kimi-k3" claude'

# Back to Claude's own login + Sonnet 5
alias kc-claude='env -u ANTHROPIC_BASE_URL -u ANTHROPIC_AUTH_TOKEN \
  -u ANTHROPIC_MODEL -u ANTHROPIC_API_KEY claude'

Now kc-kimi starts a K3 session and kc-claude starts a normal Sonnet 5 session against your Anthropic subscription — no exports linger between them because each alias scopes the variables to that one launch. When K3 throttles, Ctrl-C, type kc-claude, and you're back to work in seconds. That's the manual version of the cheap-model-with-a-frontier-backstop pattern — no gateway required.

When to actually route to K3#

The point isn't to save a few cents per million tokens — on standard pricing K3 and Sonnet 5 are close. Route to K3 when you want to spread load across providers, when you're pressure-testing an open-weight backend you can self-host once the weights drop July 27, or when you're A/B-ing the two on a real task. And judge the result the only way that's honest: cost per completed task, not the sticker price per token. For the full three-way decision — Kimi Code vs Claude Code vs Codex — we laid out who should pick which.