I’ve been running Kimi For Coding as my primary model in OpenClaw (Clawdbot) for a while now. It’s fast, has a massive context window, and supports chain-of-thought reasoning. But getting it configured properly took some trial and error. Here’s the complete setup guide.
Why Kimi For Coding?
Kimi K2.5 (via the Kimi For Coding API) offers:
- 262K context window — enough for large codebases
- 32K output tokens — can generate substantial code blocks
- Built-in reasoning — shows its work when solving problems
- Fast inference — noticeably quicker than some alternatives
The Configuration
Here’s my working clawdbot.json configuration:
{
"env": {
"vars": {
"KIMICODE_API_KEY": "sk-kimi-YOUR_API_KEY_HERE"
}
},
"models": {
"mode": "merge",
"providers": {
"kimi-code": {
"baseUrl": "https://api.kimi.com/coding/v1",
"apiKey": "sk-kimi-YOUR_API_KEY_HERE",
"api": "openai-completions",
"models": [
{
"id": "kimi-for-coding",
"name": "Kimi For Coding",
"reasoning": true,
"input": ["text"],
"contextWindow": 262144,
"maxTokens": 32768,
"headers": {
"User-Agent": "KimiCLI/0.77"
},
"compat": {
"supportsDeveloperRole": false
}
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "kimi-code/kimi-for-coding"
},
"thinkingDefault": "low",
"models": {
"kimi-code/kimi-for-coding": {
"alias": "Kimi K2.5 (Kimi Code)"
}
}
}
}
}
Critical Configuration Details
1. The User-Agent Header (Required)
This is the gotcha that trips everyone up. Kimi restricts API access to approved coding agents. You must include a recognized User-Agent:
"headers": {
"User-Agent": "KimiCLI/0.77"
}
Other working options:
claude-code/1.0.0KimiCLI/0.77
Without this, you’ll get: 403 Kimi For Coding is currently only available for Coding Agents
2. Compatibility Flag
Kimi’s API doesn’t support the developer role that some OpenAI-compatible clients use. Set this to avoid role alternation errors:
"compat": {
"supportsDeveloperRole": false
}
3. Reasoning Mode
Set "reasoning": true to enable chain-of-thought. The API returns two fields:
content— the final answer you seereasoning_content— the model’s internal thinking process
4. Thinking Level
"thinkingDefault": "low"
Options: off, minimal, low, medium, high
Toggle in Telegram: /reasoning on or /reasoning off
Troubleshooting
”Message ordering conflict” Error
Cause: Clawdbot couldn’t parse the reasoning response format.
Fix: Ensure both are set:
"reasoning": truein model config"compat": { "supportsDeveloperRole": false }
If it persists, clear sessions and restart:
# Backup first
tar -czvf ~/.clawdbot/sessions-backup.tar.gz -C ~/.clawdbot/agents/main sessions
# Clear and restart
rm -rf ~/.clawdbot/agents/main/sessions/*
npx clawdbot gateway stop && sleep 2 && npx clawdbot gateway start
403 Forbidden Error
Cause: Missing or incorrect User-Agent header.
Fix: Add the headers inside the model definition (not the provider level):
{
"id": "kimi-for-coding",
"headers": {
"User-Agent": "KimiCLI/0.77"
}
}
API Key Not Found
Note: The env.vars section does not feed into ${VAR} substitution for model configs. Put your API key directly in the provider config:
"apiKey": "sk-kimi-YOUR_ACTUAL_KEY"
Verify Everything Works
Via curl
curl -s -X POST "https://api.kimi.com/coding/v1/chat/completions" \
-H "Authorization: Bearer sk-kimi-YOUR_KEY" \
-H "User-Agent: KimiCLI/0.77" \
-H "Content-Type: application/json" \
-d '{"model":"kimi-for-coding","messages":[{"role":"user","content":"What is 47 * 83?"}]}' \
| jq '.choices[0].message'
You should see both content and reasoning_content in the response.
Via logs
tail -100 /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log | grep "thinking="
Look for: thinking=low (or your configured level)
Useful Commands
| Command | Description |
|---|---|
/new | Start fresh session |
/reasoning on | Show reasoning output |
/reasoning off | Hide reasoning (still used internally) |
/model kimi-code/kimi-for-coding | Switch to Kimi |
Summary
| Property | Value |
|---|---|
| Provider ID | kimi-code |
| Model ID | kimi-for-coding |
| Base URL | https://api.kimi.com/coding/v1 |
| Context Window | 262,144 tokens |
| Max Output | 32,768 tokens |
| Reasoning | Supported |
References
Got it working? The combination of local memory embeddings (from my previous post) plus Kimi’s reasoning makes for a surprisingly capable personal assistant setup.