Kimi (by Moonshot AI) offers a free "Kimi for Coding" tier with a dedicated API endpoint. This was the primary AI provider for PocketClaw due to its generous free tier and 262K context window. However, three issues blocked integration:
api.kimi.com/coding/v1, NOT api.moonshot.cn/v1 (the general Moonshot API)User-Agent header and returns 403 for unrecognized clients. Only known coding tools (Claude Code, Roo Code, Cursor, etc.) are allowedreasoning_content fields in responses, which confuses OpenClaw's OpenAI-compatible response parserConfigure the provider in openclaw.json:
{
"kimi-coding": {
"baseUrl": "https://api.kimi.com/coding/v1",
"apiKey": "sk-kimi-xxx",
"api": "openai-completions",
"headers": {
"User-Agent": "claude-code/1.0"
},
"models": [{
"id": "kimi-for-coding",
"name": "Kimi For Coding (K2.5)",
"contextWindow": 262144,
"maxTokens": 8192,
"reasoning": false
}]
}
}Key configuration points:
# 1. Correct endpoint (NOT moonshot.cn):
# WRONG: https://api.moonshot.cn/v1
# RIGHT: https://api.kimi.com/coding/v1
# 2. User-Agent must be a recognized coding tool:
# "claude-code/1.0" is allowed
# Default User-Agent ("node-fetch" etc.) returns 403
# 3. reasoning: false prevents K2.5 from returning
# reasoning_content fields that break the parser# Test API key validity:
curl -s -H "Authorization: Bearer sk-kimi-xxx" \
-H "User-Agent: claude-code/1.0" \
https://api.kimi.com/coding/v1/models | head -5
# Expected: JSON list of available models
# Test without correct User-Agent (should fail):
curl -s -H "Authorization: Bearer sk-kimi-xxx" \
https://api.kimi.com/coding/v1/models
# Expected: 403 Forbidden
# Test from gateway dashboard:
# Navigate to /keys -> click Test next to MOONSHOT_API_KEY
# Expected: green "OK" indicatorsk-kimi-*, different from Moonshot's sk-* formatreasoning: false is critical. With reasoning enabled, responses include reasoning_content alongside content, and OpenClaw's parser expects only content| Metric | Before | After |
|---|---|---|
| AI provider | None (setup blocked) | Kimi K2.5 free tier |
| Context window | N/A | 262K tokens |
| Monthly cost | N/A | $0 |
| Response parsing | Broken (reasoning_content) | Clean |