The Kimi API lets you build Moonshot AI's models into your own apps. It is OpenAI-compatible and Anthropic-compatible, and it runs Kimi K3.1 Pro with a 1-million-token context. This guide covers getting a key, every price, caching and batch savings, rate limits, and working code to copy.
Moonshot AI runs the Kimi API on its developer platform, platform.kimi.ai. You pay only for the tokens you use, with no subscription, and you can call it with the OpenAI or Anthropic SDKs you already know.
K3.1 Pro input and output. Cached input $0.20.
1,048,576 tokens on K3.1 Pro and K3, with flat pricing at any length.
The Batch API charges 60% of list price and skips real-time limits.
Top up $1 to unlock models. Reach $5 and get a $5 voucher.
Go to platform.kimi.ai and sign up with email or Google. This is separate from your Kimi chat plan.
Open the platform ↗Models unlock after your first successful top-up. Your total top-ups also set your rate-limit tier.
Open API keys in the console and create one. Copy it straight away and keep it secret. Never put it in front-end code.
Store it as MOONSHOT_API_KEY, then check it by listing your models.
Use the official OpenAI SDK and point it at Kimi. Pick your language:
Python needs version 3.9 or later and openai>=1.0. Swap the model ID to use another model.
A request goes to kimi-k3.1-pro, the answer streams back, and you pay for the tokens used.
Prices are in US dollars per million tokens, before tax. There are no extra charges for long inputs, and thinking tokens are billed as output.
| Model ID | Input | Cached input | Cache write (5 min / 1 h) | Output | Context | Notes |
|---|---|---|---|---|---|---|
kimi-k3.1-pro | $2.00 | $0.20 | $2.00 / $4.00 | $10.00 | 1M | Newest flagship |
kimi-k3.1-pro-highspeed | $4.00 | $0.20 | $4.00 / $8.00 | $20.00 | 1M | 2–3× faster |
kimi-k3 | $3.00 | $0.30 | Billed separately | $15.00 | 1M | Previous flagship |
kimi-k2.7-code | $0.95 | $0.19 | No charge | $4.00 | 256K | Retiring by end of Dec 2026 |
kimi-k2.6 | $0.95 | $0.16 | No charge | $4.00 | 256K | Retiring by end of Dec 2026 |
Sources: Moonshot's pricing and K3.1 Pro quickstart pages, plus published reports of the cache-write rates. On K3 models, a 5-minute cache write costs the same as normal input and a 1-hour write costs double. K2 models don't charge for cache writes.
kimi-k3.1-pro.| Tool | Endpoint | Price | What you get |
|---|---|---|---|
| Web Search Basic | /v1/tools/search | $0.002 | Titles, links and snippets |
| Web Search Pro | /v1/tools/search_pro | $0.003 | Richer search results |
| URL Fetch | /v1/tools/fetch | $0.002 | A web page as Markdown |
| Batch API | /v1/batches | 60% of list price | K3.1 Pro, K3, K2.7 Code, K2.6 |
Tool calls are billed only when they succeed with non-empty results. Search results you pass to a model count as input tokens. The older built-in $web_search tool is being replaced by these endpoints.
An estimate from list prices. It doesn't include cache-write charges on K3 models, and thinking tokens count as output.
Comparing chat plans instead? See Kimi AI pricing.
When calls are more than 5 minutes apart, the 1-hour cache costs less overall.
All examples use the Python client from the quickstart. Copy, add your own prompt, and run.
Show the model's reasoning and answer as they arrive.
Let Kimi call your functions, then send back the results.
Force output that matches your JSON schema.
Send an image with your question.
Works with K3.1 Pro, K3.1 Pro Highspeed and K3. max_tokens is required.
"partial": true to make Kimi continue your text.purpose="video" and send it as video_url with ms://<file-id>.OpenAI-compatible /v1/chat/completions. Switch existing apps by changing the base URL and model.
An Anthropic-compatible endpoint at /anthropic/v1/messages for K3.1 Pro, K3.1 Pro Highspeed and K3.
/v1/responses, with a built-in web_search tool you can switch on.
Function calling with tool_choice, plus tools you can add mid-conversation.
JSON mode and strict json_schema output for data you can parse straight away.
Send images and video with text. K3-series models understand both.
Upload files to ask questions about them or reference them as ms://<file-id>.
Automatic. Repeated prefixes bill at about a tenth of the input price.
Batch jobs at 60% of list price, and a token-estimation endpoint to plan costs.
K3.1 Pro handles some settings differently from other APIs. Most 400 errors come from these.
| Setting | How it works |
|---|---|
| reasoning_effort | low, high or max. Default is max. Use low for the fastest replies. |
| Thinking | Always on for K3.1 Pro. You can't turn it off. |
| temperature, top_p, n, penalties | Fixed (1.0, 0.95, 1, 0, 0). Leave them out of your request. |
| max_completion_tokens | Default 131,072, up to 1,048,576. Thinking counts as output. |
| Multi-turn history | Send back the full assistant message, including tool calls, not just its content. |
| Images and video | Use base64 or ms://<file-id>. Video is uploaded with purpose="video". |
Your limits depend on how much you have topped up in total. They apply to your whole account across all models, and you move up a tier automatically when you top up more.
| Tier | Total top-ups | Concurrent requests | Requests per minute | Tokens per day |
|---|---|---|---|---|
| Tier 0 | $1 (minimum) | Low | Low | 1.5M tokens |
| Tier 1 | $10 | 50 | 200 | No daily cap |
| Tiers 2–4 | Between $10 and $3,000 | Rises with each tier | Rises with each tier | No daily cap |
| Tier 5 | $3,000 | 1,000 | 10,000 | No daily cap |
Your exact limits, including tokens per minute, are shown in the console. Response headers X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset show where you stand. Vouchers don't count towards your tier.
max_completion_tokens, not just what the model actually writes. Set it close to what you need, retry with exponential backoff, and queue requests instead of sending them all at once. Need more? Contact Moonshot's sales team for a custom quota.| Kimi API | Kimi Code | Kimi app | |
|---|---|---|---|
| Best for | Building your own apps | Coding with an AI agent | Chat, research, documents |
| How you pay | Per token, prepaid balance | Included in paid Kimi plans | Free or monthly plan |
| Where you sign up | platform.kimi.ai | kimi.com | kimi.com |
| Base URL | api.moonshot.ai/v1 | api.kimi.ai/coding | None |
| Model IDs | kimi-k3.1-pro and others | k3.1-pro, kimi-for-coding and others | Chosen for you |
More on Kimi Code and all Kimi models.
More help: Kimi troubleshooting.