Ifty's BlogThoughts & Ideas
How to Use Kimi Code in Claude Code: The Complete Setup Guide (2026)

How to Use Kimi Code in Claude Code: The Complete Setup Guide (2026)

5/9/2026, 12:00:00 AM

ClaudeKimiClaude CodeKimi K2.6Kimi API

Claude Code has the best terminal UX for AI coding, but Anthropic's API costs add up fast. If you already have a Kimi membership, you can route Claude Code through Kimi's K2.6 model instead—same interface, zero extra API bills.

Here's the exact setup, including the two gotchas that cost me an hour of debugging.

What You Actually Need

  • Kimi membership: not just a Moonshot API key. You need the Kimi Code endpoint tied to your subscription.
  • API Key from the Kimi Code Console: create this. It's separate from the main Moonshot platform.
  • Claude Code installed: grab the binary from Anthropic. We're bypassing its native auth.

The Environment Variables (Exact Values)

This is where everyone trips up. Use these exact values, no trailing spaces, no substitutions.

Table

VariableCorrect Value
ANTHROPIC_BASE_URLhttps://api.kimi.com/coding/
ANTHROPIC_API_KEYYour Kimi Code key
ANTHROPIC_MODELkimi-for-coding

Critical: Use kimi-for-coding, not kimi-k2.6. The stable ID auto-maps to the latest model (currently K2.6). Using the version-specific name causes silent retry loops.

Windows (PowerShell)

$env:ANTHROPIC_BASE_URL = "https://api.kimi.com/coding/"
$env:ANTHROPIC_API_KEY = "sk-kimi-your-key-here"
$env:ANTHROPIC_MODEL = "kimi-for-coding"
$env:ANTHROPIC_SMALL_FAST_MODEL = "kimi-for-coding"

macOS/Linux

export ANTHROPIC_BASE_URL="https://api.kimi.com/coding/"
export ANTHROPIC_API_KEY="sk-kimi-your-key-here"
export ANTHROPIC_MODEL="kimi-for-coding"
export ANTHROPIC_SMALL_FAST_MODEL="kimi-for-coding"

Skip Anthropic Onboarding (The Hidden Step)

Claude Code forces an Anthropic login on first launch unless you tell it you've already onboarded. Run this once:

Windows:

node --eval "
    const fs = require('fs'), path = require('path'), os = require('os');
    const fp = path.join(os.homedir(), '.claude.json');
    let d = fs.existsSync(fp) ? JSON.parse(fs.readFileSync(fp)) : {};
    d.hasCompletedOnboarding = true;
    fs.writeFileSync(fp, JSON.stringify(d, null, 2));
"

macOS/Linux:

node -e "
    const fs = require('fs'), path = require('path'), os = require('os');
    const fp = path.join(os.homedir(), '.claude.json');
    let d = fs.existsSync(fp) ? JSON.parse(fs.readFileSync(fp)) : {};
    d.hasCompletedOnboarding = true;
    fs.writeFileSync(fp, JSON.stringify(d, null, 2));
"

Launch and Verify

claude

You should see it kimi-for-coding · API Usage Billing in the header. Type /status to confirm, then send a test message.


The 4 Gotchas That Break Everything

Table

SymptomCauseFix
"Retrying in Xs" loopsWrong endpoint, wrong model, or trailing space in URLUse api.kimi.com/coding/ and kimi-for-coding. Check for spaces.
Auth conflict warningBoth ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY setRemove-Item Env:\ANTHROPIC_AUTH_TOKEN
Prompts to log into AnthropicOnboarding flag missingRun the Node.js snippet above
"Beboppin'..."Thinking mode + tool use conflictPress Alt+T (Win) or type /effort low to disable thinking

Make It Permanent

Windows:

[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.kimi.com/coding/", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-kimi-your-key-here", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "kimi-for-coding", "User")

macOS/Linux: Add the export lines to ~/.zshrc or ~/.bashrc.


Bottom Line

Use the Kimi Code endpoint (api.kimi.com/coding/), not the Moonshot platform. Use the stable model ID (kimi-for-coding). Skip Anthropic's onboarding once. That's it—you now have Claude Code's interface running on Kimi K2.6, burning your existing membership quota instead of racking up API charges.