Setting up Moonshot AI (Kimi) in OpenClaw
I spent a lot of time trying to find an LLM that handles long context windows without costing a fortune. I eventually tried Kimi, and the speed for large files is impressive. If you are using OpenClaw, getting Moonshot (Kimi) running is pretty simple once you realize there are two separate paths you can take depending on your needs.
What You’ll Need
Section titled “What You’ll Need”- A Moonshot API key from their developer platform.
- A separate Kimi Coding key if you want to use their specialized coding models.
- OpenClaw installed on your local machine.
- Basic familiarity with your
config.json5file.
Quick Start
Section titled “Quick Start”You can get things moving in about five minutes. I recommend using the kimi-k2.5 model for general tasks because it is fast and handles long prompts well.
1. Run the Onboard Command
Section titled “1. Run the Onboard Command”Open your terminal and run the onboarding tool. If you are using the standard Moonshot API, use this:
openclaw onboard --auth-choice moonshot-api-keyIf you are specifically using Kimi Coding, run this instead:
openclaw onboard --auth-choice kimi-code-api-key2. Update Your Configuration
Section titled “2. Update Your Configuration”Open your config file and add the Moonshot provider. I usually use the .ai endpoint for international access, but you can use .cn if you are based in China. Here is the full block you can copy:
{ env: { MOONSHOT_API_KEY: "sk-..." }, agents: { defaults: { model: { primary: "moonshot/kimi-k2.5" }, models: { "moonshot/kimi-k2.5": { alias: "Kimi K2.5" }, "moonshot/kimi-k2-0905-preview": { alias: "Kimi K2" }, "moonshot/kimi-k2-turbo-preview": { alias: "Kimi K2 Turbo" }, "moonshot/kimi-k2-thinking": { alias: "Kimi K2 Thinking" }, "moonshot/kimi-k2-thinking-turbo": { alias: "Kimi K2 Thinking Turbo" }, }, }, }, models: { mode: "merge", providers: { moonshot: { baseUrl: "https://api.moonshot.ai/v1", apiKey: "${MOONSHOT_API_KEY}", api: "openai-completions", models: [ { id: "kimi-k2.5", name: "Kimi K2.5", reasoning: false, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 256000, maxTokens: 8192, }, { id: "kimi-k2-thinking", name: "Kimi K2 Thinking", reasoning: true, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 256000, maxTokens: 8192, }, ], }, }, },}Troubleshooting
Section titled “Troubleshooting”If things aren’t working as expected, check these four common issues:
- Mixing up API Keys: Moonshot and Kimi Coding are different providers. You cannot use a Moonshot key for a
kimi-coding/model. - Wrong Base URL: If you have connection timeouts, try switching between
https://api.moonshot.ai/v1andhttps://api.moonshot.cn/v1. - Model ID Prefixes: Always remember that Moonshot models need the
moonshot/prefix, while Kimi Coding useskimi-coding/. - Context Window Limits: If your long prompts are failing, check if Moonshot updated their limits and adjust the
contextWindowvalue in your config.
If you hit a wall and can’t figure out why the connection is failing, talk to the AI Setup Assistant for real-time help.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.