How to Get a Kimi API Key: Moonshot Platform in 5 Steps (2026)
You get a Kimi API key from the Moonshot AI Open Platform. Sign up, open the API key management page, create a key, add credit if the platform requires it, and then put the key in an OpenAI-compatible request. This guide walks through each step with examples you can run as-is. Menu names and page locations change when the platform is redesigned, so treat the official docs as the source of truth.
Is a Kimi API key the same as a Kimi web account?
No. Logging in to the Kimi website or app is for chatting. The API goes through the Open Platform, authenticates with a key, and bills by usage. Quotas and billing are separate, and whether any membership benefits convert into API credit is something only the official documentation can tell you. If you are still unclear on subscriptions versus the API, start with Are subscription and API models the same?
The 5 steps to get a key
- Open the Moonshot AI Open Platform and sign up or log in. Find the entry point through the official docs. Make sure you are on the official domain, and never enter account details on an unfamiliar page.
- Complete any verification the platform requires. Whether you need identity or business verification, and whether new users get free credit, changes with policy. Go by what the platform currently shows.
- Add credit if needed. Calls may fail when the balance is too low, and whether you must top up first depends on the platform's rules. For your first time, add a small amount and get the flow working before anything else.
- Create a key on the API key management page. Give it a name that tells you what it is for. A key is usually shown in full only once, at creation, so copy and save it right away.
- Send a request using the examples below.
Where should you store the key?
Don't hard-code it and don't commit it to a repository. The simplest approach is an environment variable:
export MOONSHOT_API_KEY="your key"
For team workflows and key rotation, see How to store an API key securely. If one person runs several projects, see How to manage API keys across multiple projects.
How do you make the first call?
Kimi's API is compatible with the OpenAI Chat Completions format, so curl or the OpenAI SDK both work. The base URL and model name below are examples. Replace them with the values currently given in the official docs:
curl https://api.moonshot.cn/v1/chat/completions \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model name from the official docs>",
"messages": [{"role": "user", "content": "Introduce yourself in one sentence"}]
}'
With the Python OpenAI SDK, you only change two things:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MOONSHOT_API_KEY"],
base_url="https://api.moonshot.cn/v1", # check the official docs
)
resp = client.chat.completions.create(
model="<model name from the official docs>",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
For how to structure the messages array, see What is the Chat Completions API? For why the auth header is Authorization: Bearer, see Bearer vs. x-api-key.
What if the call fails?
Check the HTTP status code first, then the error message in the response body. The table below is a general troubleshooting approach. For the exact meaning of each error code, rely on the official Moonshot documentation.
| Symptom | Common causes | What to check first |
|---|---|---|
| 401 | Wrong key, stray space or newline from copying, key was deleted | Copy the key again and confirm the header format |
| 404 | Wrong base URL or path, model name doesn't exist | Compare the path and model name with the official docs |
| 429 | Concurrency or rate limit exceeded, or insufficient balance | Read the message in the response body, then decide |
| 5xx | Server-side problem | Retry later and check service status |
429 errors are easy to confuse. For a dedicated walkthrough, see Kimi API 429 errors: engine overloaded, rate limit, or insufficient balance.
If you suspect the problem is on the platform's side, check cdnping's Moonshot API status page. It probes the official endpoint from the Cloudflare edge every 5 minutes and mirrors the official status page. You can also look at user reports on Is Kimi down?. These are external observations and do not replace official announcements.
How do you avoid unexpected charges?
- Top up in small amounts. Don't start with a large balance.
- If the platform offers spending limits or alerts, set them up as soon as you create a key. See How to set a spending limit on an AI API.
- Create separate keys for separate purposes, so a leak only means deleting one key.
- Cap
max_tokensin your code, and estimate the cost before running long-text jobs.
Is there another way, so you don't sign up with each provider?
If you already use tools like Claude Code or Codex and don't want to open accounts with each provider and deal with overseas payments, you can look at AGI Plan. It is a multi-provider LLM aggregation gateway with monthly subscriptions, billed in RMB, with no overseas credit card required. One subscription can switch between several capability groups, and tools like Claude Code and Codex only need one endpoint changed. Some models are marked as available outside China only; see the models page for details. AGI Plan is not an officially authorized channel of any model vendor. AGI Plan is a commercial partner of cdnping. A quick-start guide is at agiplan.dev/startup.
This is a different path from getting an official Kimi key. If you want Moonshot's full feature set and billing directly, apply for your own key. If you want a single entry point that switches between many models, consider a gateway. The principle is explained in How one API key can call multiple providers' models.
Next steps
- Create a key with the 5 steps above and get one curl request working.
- Move the key into an environment variable, then switch to the SDK.
- Estimate your usage before deciding how much to top up. See How to estimate LLM API costs.
- To compare latency across providers, run the online speed test on the cdnping homepage from your own network.