Guide
Kimi API Key: Moonshot AI Setup in 2026
Moonshot AI's Kimi models pair very long context with strong agentic tool-calling at a fraction of frontier pricing, which makes them a popular choice for assistants that run all day. The one detail worth getting right up front is that Moonshot operates two separate platforms, global and China, and a key issued on one does not work on the other.
Two Platforms, Two Base URLs
This is the single most common source of confusion, so it is worth stating plainly before anything else:
- Global — console at platform.moonshot.ai, API base URL
https://api.moonshot.ai/v1 - China — separate console and account system, API base URL
https://api.moonshot.cn/v1
These are distinct accounts with distinct billing. A key created on the global platform returns an auth error against the China host and vice versa. If a key that you are certain is correct keeps returning 401, checking which host you are pointed at is the first thing to try.
How to Get a Kimi API Key
- Sign up at platform.moonshot.ai for the global platform, or the China console if that is your region.
- Add a payment method and top up. The account needs a small minimum balance — around $1 — before a key will actually serve requests.
- Open the API Keys section and click Create API Key.
- Copy the key immediately. It is shown once.
Current Kimi Models
Moonshot's line-up moves quickly. As of mid-2026 the practical picture is:
- kimi-k3 — the flagship, a very large model with a 1M-token context window, priced around $3 per million input tokens and $15 per million output, with substantially cheaper cache hits.
- kimi-k2.6 and kimi-k2.7-code — the value tier at roughly $0.95 input and $4.00 output per million tokens, with the code variant tuned for programming work.
- kimi-k2.5 — cheaper still at around $0.60 input and $3.00 output.
Check the platform's own model list before hard-coding an ID. Provider catalogues change and a name that worked in a six-month-old tutorial may no longer be served.
Calling the API Directly
The Kimi API is OpenAI-compatible, so existing OpenAI SDK code works once you change the base URL and key:
curl https://api.moonshot.ai/v1/chat/completions \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k2.6",
"messages": [{"role": "user", "content": "Hello"}]
}'Swap the host for api.moonshot.cn if your account is on the China platform. Everything else about the request stays the same.
Using Your Kimi Key With an AI Assistant
If the goal is an assistant in your chat apps rather than a client you maintain, you can hand the key to a managed instance and skip the plumbing.
- Deploy an instance from the homepage — roughly 30 seconds.
- Save your Moonshot key on the API keys page. It is encrypted at rest and validated on save against both the global and China hosts, so whichever platform issued your key, a working key is accepted and a broken one is rejected on the spot.
- Select a Kimi model on your dashboard. Calls route through your own Moonshot account rather than consuming bundled AI credits.
This works for both OpenClaw and Hermes Agent. If you would rather not manage a key at all, Kimi models are also available on bundled credits with no key required.
Why Kimi for an Always-On Assistant
- Long context — the 1M-token window on the flagship keeps more conversation, files, and tool output in view during long sessions.
- Reliable tool-calling — Kimi models are tuned for agentic loops, which matters when the assistant chains several tools per turn.
- Low cost per token — the value tier is inexpensive enough to leave an assistant running continuously.
- Cache pricing — repeated system prompts and long shared context get substantially cheaper on cache hits, which suits a bot with a fixed persona.
Troubleshooting
401 Unauthorized with a key you know is correct
Almost always a platform mismatch. A global key against api.moonshot.cn, or a China key against api.moonshot.ai, fails this way. Confirm which console issued the key and match the host.
The key works but completions fail
Check the account balance. Moonshot requires a minimum top-up before keys serve traffic, and authentication succeeds independently of balance.
Model not found
The ID has probably moved. Pull the platform's current model list rather than trusting a name from an older article — Moonshot ships new versions frequently.
Rate limits during heavy use
Moonshot applies tiered rate limits that rise with account history and spend. A new account hits them sooner. If an agent makes many rapid calls, add retry with backoff rather than assuming the key is broken.