Kimi K3 API Guide: Pricing, Setup & Code Examples
Kimi K3 is Moonshot AI's flagship large language model, known for its exceptional long-context understanding and strong multilingual capabilities. With a 128K context window and competitive pricing, K3 has become a popular choice for document processing, extended conversations, and applications that need to reason over large amounts of text.
This guide covers everything you need to start using the Kimi K3 API: pricing across providers, authentication setup, complete code examples in Python and JavaScript, streaming, function calling, and best practices for production deployment.
What Makes Kimi K3 Special?
Kimi K3 builds on Moonshot AI's heritage of long-context models (their K1.5 supported 200K tokens). The K3 release in early 2026 brought significant improvements in reasoning, coding, and multilingual tasks while maintaining the model's core strength: processing long documents without losing track of details.
Key Capabilities
- 128K context window — Process ~100,000 English words or ~50,000 Chinese characters in a single request
- Strong multilingual performance — Native Chinese + English, with solid performance in Japanese, Korean, and European languages
- Function calling — OpenAI-compatible tool use for agentic workflows
- Streaming support — Sub-200ms time-to-first-token
- JSON mode — Structured output for data extraction
Pricing Comparison
| Provider | Input (1M tokens) | Output (1M tokens) | Notes |
|---|---|---|---|
| Moonshot Official | $0.60 | $1.20 | Chinese registration required |
| AIWave | $0.60 | $1.20 | No phone, global, OpenAI-compatible |
| OpenRouter | $0.72 | $1.44 | +20% routing fee |
| Together AI | $0.65 | $1.30 | Limited availability |
At $0.60/$1.20 per million tokens, Kimi K3 costs roughly 1/8th of GPT-4o ($5/$15) and 1/5th of Claude Sonnet 4 ($3/$15). For applications that need long-context processing, the savings compound quickly because long documents mean more tokens per request.
Quick Setup (5 Minutes)
Step 1: Get an API Key
The easiest path is through AIWave, which provides OpenAI-compatible access to Kimi K3 with no Chinese phone number or payment method required.
- Visit aiwave.live/console
- Create an account with your email
- Navigate to API Keys and generate a new key
- Copy the key — you'll use it in the code below
Step 2: Install the SDK
# Python
pip install openai
# JavaScript
npm install openai
Step 3: Make Your First Request
from openai import OpenAI
client = OpenAI(
api_key="your-aiwave-api-key",
base_url="https://api.aiwave.live/v1"
)
response = client.chat.completions.create(
model="kimi-k3",
messages=[
{"role": "user", "content": "Explain the difference between TCP and UDP in 3 bullet points."}
]
)
print(response.choices[0].message.content)
JavaScript / Node.js Example
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'your-aiwave-api-key',
baseURL: 'https://api.aiwave.live/v1'
});
async function summarizeDocument(text) {
const response = await client.chat.completions.create({
model: 'kimi-k3',
messages: [
{ role: 'system', content: 'Summarize the following document concisely.' },
{ role: 'user', content: text }
],
max_tokens: 1000,
temperature: 0.3
});
return response.choices[0].message.content;
}
Streaming Responses
For chatbot interfaces and real-time applications, streaming delivers a better user experience. Kimi K3 streams smoothly with minimal latency:
# Python streaming
stream = client.chat.completions.create(
model="kimi-k3",
messages=[
{"role": "user", "content": "Write a detailed guide to TypeScript generics."}
],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Long Document Processing
Where Kimi K3 really shines is processing documents that exceed the context window of most models. Here's how to use K3 for document Q&A:
def document_qa(document_text, question):
"""Answer questions about a long document using Kimi K3."""
response = client.chat.completions.create(
model="kimi-k3",
messages=[
{
"role": "system",
"content": "You are a document analysis assistant. Answer questions "
"based only on the provided document. Cite specific sections."
},
{
"role": "user",
"content": f"Document:\n{document_text}\n\nQuestion: {question}"
}
],
max_tokens=2000,
temperature=0.1 # Low temperature for factual accuracy
)
return response.choices[0].message.content
# Example: Process a 50-page contract and ask specific questions
result = document_qa(contract_text, "What is the termination clause? What notice period is required?")
Function Calling
Kimi K3 supports OpenAI-compatible function calling, enabling agentic workflows:
tools = [
{
"type": "function",
"function": {
"name": "search_database",
"description": "Search the product database for items matching a query",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"},
"category": {"type": "string"},
"max_price": {"type": "number"}
},
"required": ["query"]
}
}
},
{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Get the status of an order by ID",
"parameters": {
"type": "object",
"properties": {
"order_id": {"type": "string"}
},
"required": ["order_id"]
}
}
}
]
response = client.chat.completions.create(
model="kimi-k3",
messages=[{"role": "user", "content": "Find me wireless headphones under $50 and check order #12345"}],
tools=tools,
tool_choice="auto"
)
# K3 will correctly route to both tools
for tool_call in response.choices[0].message.tool_calls:
print(f"Call: {tool_call.function.name}({tool_call.function.arguments})")
Production Best Practices
Context Window Management
With 128K tokens, it's tempting to stuff everything into the context. However, longer contexts mean higher costs and slower responses. Use these strategies:
- Chunking: Split large documents into 20K-30K token chunks and process them separately, then merge results
- RAG over long context: For retrieval tasks, embedding-based RAG is often cheaper than sending the full document
- Sliding window: For multi-turn conversations, keep the system prompt + last N turns instead of full history
Error Handling
import openai
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=1, max=10))
def call_kimi(messages, **kwargs):
try:
return client.chat.completions.create(
model="kimi-k3",
messages=messages,
**kwargs
)
except openai.RateLimitError:
raise # Retry will handle this
except openai.APIError as e:
if e.status_code >= 500:
raise # Server error, retry
raise # Client error, don't retry
Caching Strategy
For deterministic tasks (classification, extraction), implement response caching keyed on the input hash. This can reduce API calls by 20-40% in typical workloads.
Kimi K3 vs. Competitors
| Feature | Kimi K3 | DeepSeek V4 | GLM-5 | GPT-4o |
|---|---|---|---|---|
| Context Window | 128K | 128K | 128K | 128K |
| Input Price/1M | $0.60 | $0.27 | $0.50 | $5.00 |
| Output Price/1M | $1.20 | $1.10 | $1.00 | $15.00 |
| MMLU | 86.1% | 88.7% | 87.3% | 88.7% |
| Chinese Tasks | Excellent | Excellent | Excellent | Good |
| Long Doc QA | Best-in-class | Very Good | Very Good | Good |
Frequently Asked Questions
How much does Kimi K3 API cost?
Kimi K3 costs $0.60 per million input tokens and $1.20 per million output tokens through AIWave. That's roughly 1/8th the cost of GPT-4o and 1/5th the cost of Claude Sonnet 4.
What is the context window of Kimi K3?
Kimi K3 supports up to 128,000 tokens of context, enough for processing 100+ page documents, long codebases, or extended conversations with full history.
Can I use Kimi K3 for Chinese text processing?
Yes. Kimi K3 is developed by Moonshot AI (a Chinese company) and has excellent native Chinese language capabilities. It handles both Simplified and Traditional Chinese, and performs well on Chinese-specific NLP tasks like document summarization, sentiment analysis, and legal text processing.
Does Kimi K3 support vision/image input?
The text-only Kimi K3 model does not support image input. For multimodal tasks, check out Kimi's vision-capable variants or alternatives like Qwen-VL through AIWave.
Ready to Get Started?
Access Kimi K3 and 50+ Chinese AI models through one OpenAI-compatible API. No Chinese phone number required.
Get Your API Key →