Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Setup guide - Documented by Kimi

Use Kimi in Claude Code

Moonshot publishes a Claude Code guide. You point Claude Code at Kimi's Anthropic-compatible Messages endpoint (https://api.moonshot.ai/anthropic) through the env block in ~/.claude/settings.json, with every model tier mapped to a Kimi model id. Claude Code's own env-var reference documents ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, the ANTHROPIC_DEFAULT_*_MODEL tiers, CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_EFFORT_LEVEL.

Last verified 5 steps5 official sources

Steps

  1. Step 1.

    Install Claude Code (native installer, macOS and Linux).

    Terminal
    curl -fsSL https://claude.ai/install.sh | bash
  2. Step 2.

    Create an API key on the Kimi Platform (https://platform.kimi.ai/console/api-keys) and use it to replace YOUR_MOONSHOT_API_KEY below.

  3. Step 3.

    Write the following variables into the env field of ~/.claude/settings.json, then restart Claude Code. This example sets the HAIKU tier to kimi-k2.7-code and every other tier to kimi-k3[1m].

    JSON
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.moonshot.ai/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "YOUR_MOONSHOT_API_KEY",
        "ANTHROPIC_MODEL": "kimi-k3[1m]",
        "ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k3[1m]",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-k3[1m]",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-k2.7-code",
        "ANTHROPIC_DEFAULT_FABLE_MODEL": "kimi-k3[1m]",
        "CLAUDE_CODE_SUBAGENT_MODEL": "kimi-k3[1m]",
        "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
        "CLAUDE_CODE_EFFORT_LEVEL": "max"
      }
    }
  4. Step 4.

    Check the endpoint and key with curl. A normal JSON response means both work; a 401 means the key is invalid or belongs to a different platform.

    Terminal
    curl https://api.moonshot.ai/anthropic/v1/messages \
      --header "Authorization: Bearer YOUR_MOONSHOT_API_KEY" \
      --header "Content-Type: application/json" \
      --data '{"model": "kimi-k3", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]}'
  5. Step 5.

    Start Claude Code and enter /status. Base URL should show https://api.moonshot.ai/anthropic and Model should show kimi-k3[1m]. Then send any message (for example hello) to confirm the setup works end to end.

    Snippet
    /status

Caveats

  • Kimi's guide warns that configuring only some of the variables makes the matching scenarios (background tasks, sub-agents) fail silently. Set every tier.
  • kimi-k2.7-code has thinking forced on. You must enable Thinking in Claude Code (Option+T on macOS, Alt+T on Windows/Linux) first, or requests are rejected with: 400 invalid thinking: only type=enabled is allowed for this model
  • The env block in settings.json overrides same-named variables exported in your terminal, and it holds the API key in plain text. Do not commit it.
  • If ANTHROPIC_API_KEY was set before, remove it to avoid conflicts with ANTHROPIC_AUTH_TOKEN.
  • Keys created on platform.kimi.ai must be used with the api.moonshot.ai endpoint shown here.

FAQ

How do I use Kimi in Claude Code?

Moonshot publishes a Claude Code guide. You point Claude Code at Kimi's Anthropic-compatible Messages endpoint (https://api.moonshot.ai/anthropic) through the env block in ~/.claude/settings.json, with every model tier mapped to a Kimi model id. Claude Code's own env-var reference documents ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, the ANTHROPIC_DEFAULT_*_MODEL tiers, CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_EFFORT_LEVEL.

Which Kimi model ids work in Claude Code?

The official docs read for this guide list kimi-k3[1m], kimi-k3, kimi-k2.7-code and kimi-k2.6. Requests go to https://api.moonshot.ai/anthropic.

Is this an official Kimi and Claude Code setup?

Kimi documents this setup in its own docs. It was last checked against 5 official pages on October 17, 2026.

Sources

Last verified against 5 official pages.

Newsletter

New models, set up the day they ship

One email per week. New model releases, the coding tools that support them and how to wire them up.