Skip to content

How to Run Kimi K2 Thinking With Claude Code

Run Kimi K2 Thinking with Claude Code using Moonshot's Anthropic-compatible endpoint — no proxy. API key, environment variables, model choice, pricing, and fixes.

MGMCSA Guru Team July 7, 2026 3 min read
Claude Code on Windows running Kimi K2 Thinking via Moonshot's endpoint

Kimi K2 Thinking is Moonshot’s reasoning model, tuned for multi-step problem solving and strong agentic behavior — a good fit when a task needs deliberate thinking rather than a quick guess. And because Moonshot ships an Anthropic-compatible endpoint, running it with Claude Code takes no proxy at all, just two environment variables.

This is the setup, the model choice, and the pricing picture. For the no-proxy approach generally, see anthropic-compatible endpoints.

Step 1: Get a Moonshot API key

Sign up on the Moonshot platform, add a little credit, and generate an API key. Kimi is pay-per-token, so a small top-up covers a lot of coding.

Step 2: Make sure Claude Code is installed

npm install -g @anthropic-ai/claude-code

Step 3: Point Claude Code at Kimi

Moonshot’s Anthropic-compatible endpoint is the key. In WSL (recommended on Windows):

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

On native Windows PowerShell:

$env:ANTHROPIC_BASE_URL = "https://api.moonshot.ai/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-moonshot-key"
$env:ANTHROPIC_MODEL = "kimi-k2-thinking"
claude

Confirm the exact base URL and model ID in Moonshot’s docs, since they change with releases.

Step 4: Pick the model

Kimi K2 models (confirm IDs on Moonshot)

kimi-k2-thinking Reasoning mode; multi-step problem solving
kimi-k2 (turbo variants) Faster, cheaper responses

Use K2 Thinking for hard, multi-step tasks and a faster K2 variant for quick everyday work. Set ANTHROPIC_MODEL accordingly.

Pricing

Kimi is primarily pay-per-token, billed per million input/output tokens, with cache-hit discounts when prompts reuse context. There isn’t a flat coding plan in the GLM/Alibaba sense, so cost scales with use — though the rates are low and cache hits help during agent sessions. Confirm current numbers on Moonshot’s docs; full detail in Kimi K2 pricing explained.

Verify

claude
# then: "explain this module and suggest a refactor"

If it reads files and reasons through the answer, Kimi is serving Claude Code.

Troubleshooting

  • Auth errors — token not set in the current shell, or wrong key.
  • Format errors — you’re on /v1; switch to /anthropic.
  • “Model not found” — confirm the exact Kimi model ID on Moonshot’s docs.
  • Slow/expensive — you’re on Thinking mode; switch to a faster variant for routine work.

Kimi + Claude Code checklist

  • Moonshot API key created and funded
  • Claude Code installed
  • ANTHROPIC_BASE_URL set to the /anthropic endpoint
  • ANTHROPIC_AUTH_TOKEN and ANTHROPIC_MODEL set
  • Thinking for hard tasks, fast variant for routine work

Wrapping up

Running Kimi K2 Thinking with Claude Code needs no proxy: set ANTHROPIC_BASE_URL to Moonshot’s /anthropic endpoint, add your token, and choose kimi-k2-thinking. It’s pay-per-token with cache discounts, so reserve Thinking mode for tasks that need it and use a faster variant otherwise.

To use Kimi elsewhere, see Kimi K2 with Codex CLI or Kimi K2.5 Turbo + OpenCode.

Frequently asked questions

Can Claude Code run on Kimi K2 without a proxy?

Yes. Moonshot exposes an Anthropic-compatible endpoint, so you point Claude Code at it with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN — no Claude Code Router needed for the common case.

What's special about Kimi K2 Thinking?

K2 Thinking is the reasoning variant of Moonshot's K2 family, tuned for multi-step problem solving and strong agentic behavior. It's a good pick when tasks need deliberate reasoning rather than quick answers.

Does Kimi have a coding plan or just pay-per-token?

Kimi is primarily pay-per-token, billed per million input/output tokens, with cache-hit discounts. There isn't a flat coding plan in the way GLM or Alibaba offer, so cost scales with usage. Confirm current rates on Moonshot's docs.

What's the Anthropic endpoint for Kimi?

Moonshot's Anthropic-compatible base URL (commonly https://api.moonshot.ai/anthropic). Set it as ANTHROPIC_BASE_URL. Confirm the exact path in Moonshot's platform docs.

Which Kimi model should I set?

kimi-k2-thinking for reasoning-heavy work, or a faster K2 variant (like a Turbo model) for quicker, cheaper responses. Set ANTHROPIC_MODEL to the model ID from Moonshot's docs.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.