API Documentation
Quick start guides for integrating Kimi K3 into your applications.
Python Example (OpenAI-compatible)
from openai import OpenAI
client = OpenAI(
base_url="https://api.moonshot.cn/v1",
api_key="your-api-key-here"
)
response = client.chat.completions.create(
model="kimi-k3",
messages=[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function to sort a list."}
],
max_tokens=4096
)
print(response.choices[0].message.content)
cURL Example
curl https://api.moonshot.cn/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "kimi-k3",
"messages": [
{"role": "user", "content": "Explain quantum computing in simple terms."}
],
"temperature": 0.7
}'
💡 Note: The Kimi K3 API is OpenAI-compatible. You can use the same client libraries across Moonshot AI, OpenRouter, Together AI, DeepInfra, and other providers by changing the
base_url.