← All guides

How to use Kimi in Claude Code

Moonshot's Kimi models (the K2 line) have become a popular cheap-but-capable choice for agent coding, and Claude Code can run on them. Here's how to connect Kimi, what to check, and a cleaner path when you want to switch models freely.

TL;DR: Moonshot exposes an Anthropic-compatible endpoint for Kimi, so you can run Claude Code on it: set ANTHROPIC_BASE_URL to Moonshot's Anthropic base and ANTHROPIC_AUTH_TOKEN to your Moonshot key, then pick a Kimi model. It's a strong value pick for everyday coding, but it's a global endpoint swap — switching back to Claude means editing env vars and restarting. An agent that treats the model as a setting avoids that.

Kimi + Claude Code: the short version

Kimi is served by Moonshot, which publishes an Anthropic-compatible endpoint precisely so Claude Code and similar tools can point at it directly. You supply your own Moonshot key, usage is billed to you, and there's no translating proxy required — Claude Code talks to Kimi as if it were an Anthropic endpoint.

The config

What to set

  1. ANTHROPIC_BASE_URLPoint it at Moonshot's Anthropic-compatible base URL (the /anthropic endpoint).
  2. ANTHROPIC_AUTH_TOKENYour Moonshot API key — usage billed to your Moonshot account.
  3. ModelSelect a Kimi model (e.g. the K2 line). Use the exact name the endpoint exposes.
# Point Claude Code at Moonshot/Kimi's Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-moonshot-key"
# then run claude as usual, selecting a Kimi model
Reality check: this is a global switch. There's no in-app 'Kimi for this, Claude for that' — you change env vars and restart to move between them. Check whether your key is on the international (.ai) or mainland (.cn) endpoint and match the base URL accordingly.

Why route Claude Code to Kimi

Value

Kimi's K2 line is a strong capability-per-dollar pick for everyday agent coding.

Long context

Kimi is known for large context windows, handy for bigger codebases.

Fallback for Claude limits

Somewhere to route when your Claude plan is rate-limited or capped.

The cleaner option: Kimi as a one-click setting

The endpoint swap works, but Claude Code is single-provider by design, so mixing Kimi and Claude means reconfiguring each time. If you want to run Kimi most of the time and jump to Claude (or a local model) on demand, use an agent where the provider, base URL, key and model are settings you pick from a list.

What that looks like with Wuwei

Kimi in the model list

Pick it in the UI; Claude, GLM, DeepSeek, Qwen and OpenAI-compatible endpoints sit alongside.

One-click switch

Move between Kimi and Claude mid-task without editing config or restarting.

Free, open source, local

MIT-licensed, runs on your machine, reads your real files; you only pay Moonshot's usage.

FAQ

Can Claude Code use Kimi?

Yes. Moonshot exposes an Anthropic-compatible endpoint for Kimi. Set ANTHROPIC_BASE_URL to Moonshot's /anthropic base and ANTHROPIC_AUTH_TOKEN to your Moonshot key, then select a Kimi model — no proxy needed.

Is Kimi good for coding agents?

Kimi's K2 line is a popular value pick for agent coding, with strong capability per dollar and large context windows that help on bigger repos.

How do I switch between Kimi and Claude easily?

Use an agent where the model is a setting. Wuwei is free and open source — Kimi and Claude are both in the model list, so switching is one click rather than an env-var edit and restart.

If you want agent coding on Kimi's cheap, long-context models — with Claude a click away when you need it — Wuwei is a free, open-source agent that puts both in one model list. Bring your Moonshot key, pick Kimi, and run locally on your real files.

Windows · macOS · Linux — free, no login