Kimi API Guide for International Developers (2026)
Kimi — built by Moonshot AI — is one of China's top large language models, known for its 200K context window and exceptional long-form reasoning. If you're a developer outside China, this guide covers everything: how to access it, pricing, model selection, and code examples.
⚡ Use Kimi API in 5 Minutes — No Chinese Phone Number
OpenAI-compatible endpoint. $0.20 starter credit. Start building immediately.
Get Started →Kimi and Moonshot models on AIWave (USD per 1M tokens)
| Model | Input | Output | Cache hit (input) | Best for |
|---|---|---|---|---|
| kimi-k2.5 | $0.660 | $3.300 | $0.122 | Long-context reasoning, agents, coding |
| kimi-k3 | $4.500 | $22.500 | $0.900 | Hardest agentic + long-doc work only |
| moonshot-v1-8k | $0.300 | $2.200 | — | Short prompts, most cost-effective entry point |
| moonshot-v1-32k | $0.950 | $2.850 | — | Medium context, drafting, summaries |
Rates read from AIWave's live pricing endpoint; check it before budgeting since providers revise rates.
Read the output column before you commit
The input prices make Kimi look cheap. The output prices are where it bites. kimi-k2.5's $3.300/1M output is 9x deepseek-chat's $0.364 for the same generated token, and kimi-k3 at $22.500/1M output is a genuinely expensive model — 6.8x kimi-k2.5 and roughly 62x deepseek-chat. Kimi earns those numbers on one axis: context. If your task does not actually need a very long window, you are paying a long-context premium for nothing, and a DeepSeek or GLM model does the same job for a fraction of the output cost.
The practical rule: reach for Kimi when the prompt genuinely spans an entire codebase, a long PDF, or a multi-document research set. For short chat, classification, or extraction, moonshot-v1-8k at $0.300/$2.200 is the cheap entry point, and models outside the Kimi family are usually cheaper still.
The cache discount changes the math on repeated prompts
kimi-k2.5 bills cached input at $0.122/1M against a $0.660 base — an 81% cut on any prefix the platform has already processed. For long-context work this matters more than for anyone else, because the expensive part of a long-context call is the input you resend every turn. Pin the big document as a stable prefix, keep the variable question last, and repeated turns over the same document are billed at the cache rate. Break the prefix — inject a turn counter, reorder the context — and every token reverts to full price.
Python Quickstart
import openai
client = openai.OpenAI(
base_url="https://aiwave.live/v1",
api_key="sk-your-aiwave-key"
)
response = client.chat.completions.create(
model="kimi-k2",
messages=[{"role": "user", "content": "Explain quantum computing in one paragraph"}]
)
print(response.choices[0].message.content)
Node.js Quickstart
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://aiwave.live/v1',
apiKey: 'sk-your-aiwave-key'
});
const response = await client.chat.completions.create({
model: 'kimi-k2',
messages: [{ role: 'user', content: 'Write a haiku about AI' }]
});
console.log(response.choices[0].message.content);
curl Quickstart
Same endpoint, same JSON contract as OpenAI — handy for a shell smoke test:
curl https://aiwave.live/v1/chat/completions \
-H "Authorization: Bearer sk-your-aiwave-key" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k2.5",
"messages": [{"role": "user", "content": "Summarize the attached RFC in 5 bullets: ..."}],
"max_tokens": 600
}'
Long-context in practice
Kimi's reason for existing is the long window, so here is the shape that actually uses it: load a large document once as a system-level prefix, then ask questions against it. Keep the document first and stable so the cache can catch it on later turns.
from openai import OpenAI
client = OpenAI(base_url="https://aiwave.live/v1", api_key="sk-your-aiwave-key")
with open("spec.md") as f:
doc = f.read() # a long document: an RFC, a codebase dump, a paper
resp = client.chat.completions.create(
model="kimi-k2.5",
messages=[
{"role": "system", "content": "Answer only from the document below.\n\n" + doc},
{"role": "user", "content": "List every backwards-incompatible change."},
],
)
u = resp.usage
print(u.prompt_tokens, "input tokens") # long docs make input the dominant cost
print(resp.choices[0].message.content)
Watch prompt_tokens: on a long-context call the input dwarfs the output, which is exactly why the $0.122 cache rate on kimi-k2.5 is the number that decides whether the workload is affordable.
Which Kimi model to pick
- moonshot-v1-8k ($0.300/$2.200) — short prompts where you still want Moonshot quality. The most cost-effective way in.
- moonshot-v1-32k ($0.950/$2.850) — medium context: drafting, summaries, single-document Q&A.
- kimi-k2.5 ($0.660/$3.300, cache $0.122) — the default for long-context reasoning, agents, and coding. The cache rate makes multi-turn work over one big document viable.
- kimi-k3 ($4.500/$22.500) — reserve for the hardest agentic and long-document tasks where k2.5 measurably fails. At $22.5/1M output, route to it deliberately, never by default.
Why Use Kimi via AIWave Instead of Directly?
| Feature | Direct Moonshot API | Via AIWave |
|---|---|---|
| Chinese phone number required | ❌ Yes | ✅ No |
| Payment methods | Alipay/WeChat only | USD, card payments, Stripe |
| API format | Custom Moonshot format | OpenAI-compatible |
| Multi-model access | Kimi only | Kimi + DeepSeek + GLM + 50+ |
| prepaid credits | Varies | $1 (1.5M+ input tokens) |
| Rate limiting | Per-account | Aggregated, higher limits |
When to Choose Kimi Over Other Models
- Genuinely long context: whole books, full codebases, multi-document research sets — this is the one axis where paying Kimi's output premium is justified.
- Long-document agents: kimi-k2.5's $0.122 cache rate keeps multi-turn work over a fixed large document affordable in a way short-context models cannot match.
- Bilingual Chinese-English: native-level Chinese with strong English, useful for cross-language extraction and translation.
- When you would not pick Kimi: short chat, classification, or extraction. kimi-k2.5 output at $3.300/1M is 9x deepseek-chat — on short tasks a DeepSeek or GLM model does the same job far cheaper.
kimi-k1.5 for bulk processing tasks and kimi-k2 for quality-critical operations. Combine with DeepSeek-Reasoner for math-heavy workloads.
Function calling with Kimi
kimi-k2.5 supports OpenAI-style tool calling, which is what turns it into an agent rather than a chatbot. You declare tools, the model returns a structured call, you execute it and feed the result back — the same schema you already use with OpenAI:
from openai import OpenAI
client = OpenAI(base_url="https://aiwave.live/v1", api_key="sk-your-aiwave-key")
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
resp = client.chat.completions.create(
model="kimi-k2.5",
messages=[{"role": "user", "content": "What should I pack for Shanghai today?"}],
tools=tools,
)
call = resp.choices[0].message.tool_calls[0]
print(call.function.name, call.function.arguments) # get_weather {"city": "Shanghai"}
For agent loops the output rate is the thing to watch: every reasoning step is billable output at $3.300/1M, so a chatty ten-step agent on kimi-k2.5 can cost more than the single task it is automating. Cap the step count and set max_tokens.
Pairing Kimi with a cheaper fallback
The pattern that keeps long-context costs sane: default to a cheap model and escalate to Kimi only when the input is actually long. One base_url, so the switch is a string:
def choose_model(prompt_tokens):
if prompt_tokens > 60_000:
return "kimi-k2.5" # long context earns Kimi's premium
return "deepseek-chat" # 9x cheaper output for everything else
model = choose_model(count_tokens(prompt))
resp = client.chat.completions.create(model=model, messages=messages)
Route by the one variable that justifies Kimi — input length — and most of your traffic never touches the expensive path.
Kimi vs DeepSeek vs GLM for the same task
Kimi is not the most cost-effective model on AIWave and it is not trying to be. It occupies one niche — long context — and the pricing reflects that. The honest trade, output rate side by side:
| Model | Output $/1M | Pick it when |
|---|---|---|
| deepseek-chat | $0.364 | General chat, extraction, most work — 9x cheaper output |
| glm-4.7 | $3.410 | Balanced reasoning, agent loops, tool use |
| kimi-k2.5 | $3.300 | The prompt genuinely spans a long document or codebase |
| kimi-k3 | $22.500 | Only the hardest long-context agentic tasks |
kimi-k2.5 and glm-4.7 output cost almost the same ($3.30 vs $3.41). At that point the deciding question is context: if you need to reason across 128K+ of input, Kimi's window and its $0.122 cache rate win. If you do not, glm-4.7 is the safer generalist and deepseek-chat is far cheaper.
Getting a key and your first call
The reason to go through AIWave rather than Moonshot directly is that there is no Chinese phone number and no Alipay. Sign in with email or GitHub at the console, create a key, and the code above works immediately — the $0.20 starter credit runs a few million tokens of moonshot-v1-8k while you evaluate. Set the key as an environment variable rather than hard-coding it:
export AIWAVE_KEY="sk-your-aiwave-key"
# read os.environ["AIWAVE_KEY"] (Python) or process.env.AIWAVE_KEY (Node)
Rotating a leaked key then becomes a config change, not a code deploy.
Long-context gotchas worth knowing
- Input dominates the bill. On a 100K-token prompt the input cost swamps the output. This is the one case where the input price, and the cache rate, matter more than output.
- Latency scales with context. A full 128K prompt takes meaningfully longer to first token than a 2K one. Stream, and do not send context you do not need.
- "Lost in the middle" is real. Models attend less reliably to material buried in the center of a very long prompt. Put the question and the most relevant passages near the start or end.
- Chunk when you can. If a task splits cleanly, running moonshot-v1-8k over chunks can beat one giant kimi-k3 call on both cost and quality.
Common errors and how to read them
- 401 Unauthorized — wrong or missing key. Check the
Authorization: Bearerheader and that you copied the wholesk-string. - 400 context length exceeded — prompt plus
max_tokensis over the window. Trim input or lowermax_tokens; do not just retry. - 429 rate limit — back off and retry with exponential delay. Aggregated limits on AIWave beat a single Moonshot account, but they are not infinite.
- Truncated output — almost always
max_tokenstoo low. Inspectfinish_reason; "length" means you were cut off.
Why long context is priced the way it is
It helps to know what you are paying for. Attention cost grows with sequence length, so a 128K-token prompt is genuinely more expensive to serve than a 4K one — the provider spends more compute per request. That is why kimi-k3 output sits at $22.500/1M, and why the cache rate exists at all: reprocessing the same long prefix every turn is the expensive part, so billing it once at $0.900 (k3) or $0.122 (k2.5) and reusing it is how long-context work stays viable. Design around that and Kimi is a scalpel; ignore it and the bill balloons.
Streaming and timeouts on long prompts
A 128K-token call can take tens of seconds to first token, and the default HTTP timeout in most SDKs fires before a large completion finishes. Two fixes: stream, so you render tokens as they arrive instead of blocking on the whole response, and raise the client timeout explicitly for long-context work.
client = OpenAI(base_url="https://aiwave.live/v1",
api_key="sk-your-aiwave-key",
timeout=120.0) # seconds; the default is too low for 128K prompts
stream = client.chat.completions.create(
model="kimi-k2.5", stream=True, messages=messages)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
Streaming also improves perceived latency, which on a slow long-context model is the difference between "thinking" and "hung".
The short version
Kimi is a long-context specialist priced like one. moonshot-v1-8k ($0.300/$2.200) is the cheap entry, kimi-k2.5 ($0.660/$3.300, cache $0.122) is the workhorse for documents and agents, and kimi-k3 ($4.500/$22.500) is the break-glass model for the hardest long-context jobs. The output price decides everything: at $3.300/1M, kimi-k2.5 is 9x deepseek-chat, so use Kimi when the window is the point and route ordinary generation to a cheaper model. Build a length-based switch, lean on the cache rate for repeated prefixes, and the long context becomes an asset instead of a line item.
Related Guides
- DeepSeek vs GLM vs Kimi: Full Comparison →
- Chinese AI Pricing 2026: Real Numbers →
- Migrate from OpenAI to Chinese AI →
- Multi-Model Fallback Patterns →
Kimi API pricing · Qwen API pricing · ERNIE API pricing · OpenAI-compatible API docs · Chinese model comparison