Claude Code
Claude Code is a programming agent product from Anthropic. Its interface, configuration options, and supported capabilities may change across versions. This guide describes a general integration approach: forwarding Claude Code model requests to the Kimi Code API through environment variables.
Before You Start
- Make sure you have subscribed to Kimi membership and activated Kimi Code benefits.
- Obtain an API Key:
- Go to the Kimi Code Console;
- Click "Create API Key", enter a name and confirm;
- Copy the generated key and keep it safe (the full key cannot be viewed again after closing the dialog).

Configuration
Claude Code is a command-line programming assistant launched by Anthropic. By configuring environment variables to connect it to Kimi's API endpoint, you can directly call Kimi Code's AI capabilities within Claude Code and enjoy the Kimi Code programming experience in a familiar terminal interface.
① Install Claude Code
For installation instructions, please refer to the Claude Code official documentation.
│
② Run Script to Skip Login
After installation, do not start Claude directly. Execute the following script in the terminal first to skip Anthropic's default login flow:
shnode --eval " // enable third party model support and fast mode const claudeJsonFilePath = path.join(os.homedir(), '.claude.json'); if (fs.existsSync(claudeJsonFilePath)) { const content = JSON.parse(fs.readFileSync(claudeJsonFilePath, 'utf-8')); fs.writeFileSync(claudeJsonFilePath, JSON.stringify({ ...content, penguinModeOrgEnabled: true, hasCompletedOnboarding: true }, null, 2), 'utf-8'); } else { fs.writeFileSync(claudeJsonFilePath, JSON.stringify({ penguinModeOrgEnabled: true, hasCompletedOnboarding: true }), 'utf-8'); } // delete old model id const claudeSettingsJsonFilePath = path.join(os.homedir(), '.claude', 'settings.json'); if (fs.existsSync(claudeSettingsJsonFilePath)) { const content = JSON.parse(fs.readFileSync(claudeSettingsJsonFilePath, 'utf-8')); if (typeof content === 'object' && typeof content.env === 'object') { for (const element of [ 'ANTHROPIC_MODEL', 'ANTHROPIC_SMALL_FAST_MODEL', 'CLAUDE_CODE_SUBAGENT_MODEL', 'ANTHROPIC_DEFAULT_FABLE_MODEL', 'ANTHROPIC_DEFAULT_FABLE_MODEL_NAME', 'ANTHROPIC_DEFAULT_OPUS_MODEL', 'ANTHROPIC_DEFAULT_OPUS_MODEL_NAME', 'ANTHROPIC_DEFAULT_SONNET_MODEL', 'ANTHROPIC_DEFAULT_SONNET_MODEL_NAME', 'ANTHROPIC_DEFAULT_HAIKU_MODEL', 'ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME', ]) { delete content.env[element]; } fs.writeFileSync(claudeSettingsJsonFilePath, JSON.stringify(content, null, 2), 'utf-8'); } } "
│
③ Set Environment Variables and Start
First check your membership tier to confirm which models and context windows you can use, then copy the matching configuration:
| Plan | Available Models | Available Context Limit |
|---|---|---|
| Andante | kimi-for-coding | 262144 |
| Moderato | k3 or kimi-for-coding | 262144 |
| Allegretto and above | k3, kimi-for-coding, kimi-for-coding-highspeed | 1048576 for K3, 262144 for the K2.7 Code series |
K3 1M context configuration:
The k3[1m] form is only needed for Claude Code env vars
k3[1m] (with the surrounding quotes) explicitly tells Claude Code to use a 1M context window. In any other scenario — API requests, the Model ID field of other third-party tools — just use k3.
export ANTHROPIC_BASE_URL=https://api.kimi.com/coding/
export ANTHROPIC_API_KEY=Your API Key
export ANTHROPIC_MODEL="k3[1m]"
export ANTHROPIC_DEFAULT_FABLE_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_OPUS_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_SONNET_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_HAIKU_MODEL=$ANTHROPIC_MODEL
export CLAUDE_CODE_SUBAGENT_MODEL=$ANTHROPIC_MODEL
export CLAUDE_CODE_EFFORT_LEVEL=high
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=1048576
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048576
claude$env:ANTHROPIC_BASE_URL="https://api.kimi.com/coding/"
$env:ANTHROPIC_API_KEY="Your API Key"
$env:ANTHROPIC_MODEL="k3[1m]"
$env:ANTHROPIC_DEFAULT_FABLE_MODEL=$env:ANTHROPIC_MODEL
$env:ANTHROPIC_DEFAULT_OPUS_MODEL=$env:ANTHROPIC_MODEL
$env:ANTHROPIC_DEFAULT_SONNET_MODEL=$env:ANTHROPIC_MODEL
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL=$env:ANTHROPIC_MODEL
$env:CLAUDE_CODE_SUBAGENT_MODEL=$env:ANTHROPIC_MODEL
$env:CLAUDE_CODE_EFFORT_LEVEL="high"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="1048576"
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS="1048576"
claudeUsers with K3 256K-only access should use the configuration below:
export ANTHROPIC_BASE_URL=https://api.kimi.com/coding/
export ANTHROPIC_API_KEY=Your API Key
export ANTHROPIC_MODEL=k3
export ANTHROPIC_DEFAULT_FABLE_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_OPUS_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_SONNET_MODEL=$ANTHROPIC_MODEL
export ANTHROPIC_DEFAULT_HAIKU_MODEL=$ANTHROPIC_MODEL
export CLAUDE_CODE_SUBAGENT_MODEL=$ANTHROPIC_MODEL
export CLAUDE_CODE_EFFORT_LEVEL=high
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=262144
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=262144
claude$env:ANTHROPIC_BASE_URL="https://api.kimi.com/coding/"
$env:ANTHROPIC_API_KEY="Your API Key"
$env:ANTHROPIC_MODEL="k3"
$env:ANTHROPIC_DEFAULT_FABLE_MODEL=$env:ANTHROPIC_MODEL
$env:ANTHROPIC_DEFAULT_OPUS_MODEL=$env:ANTHROPIC_MODEL
$env:ANTHROPIC_DEFAULT_SONNET_MODEL=$env:ANTHROPIC_MODEL
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL=$env:ANTHROPIC_MODEL
$env:CLAUDE_CODE_SUBAGENT_MODEL=$env:ANTHROPIC_MODEL
$env:CLAUDE_CODE_EFFORT_LEVEL="high"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="262144"
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS="262144"
claudeEnvironment Variable Reference
| Variable | Purpose |
|---|---|
ANTHROPIC_MODEL | The model applied by the current configuration |
CLAUDE_CODE_EFFORT_LEVEL | Default thinking effort level; set to high in the configuration |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | Threshold for auto-compaction |
CLAUDE_CODE_MAX_CONTEXT_TOKENS | Maximum context token budget |
Switching thinking effort
After starting, type /effort in a session to switch thinking effort levels — no environment variable needed. K3 supports low / high / max; the mapping from Claude Code levels to K3 levels is:
| Claude Code level | K3 level |
|---|---|
low | low |
medium | high (recommended) |
high | high (recommended) |
xhigh | max |
max | max |
| Not set (default) | high |
Note
Disabling thinking routes both K3 and K2.7 Code to K2.6. Keep Thinking on to use K3 / K2.7; for K2.7 Code the shortcut is Option+T on macOS and Alt+T on Windows / Linux.
If prompted whether to use this API key, confirm to proceed. Afterwards, follow the prompts to select your trusted project folder to complete the authorization.
│
④ Verify After Starting
After starting, enter /status. If the returned information shows Base URL as https://api.kimi.com/coding/, the configuration is successful. Even if the model name still appears as a Claude model, the actual calls are still made to the Kimi Code API.

│
