Access DeepSeek, GLM, and China's top AI models through one OpenAI-compatible API.
sk-
curl https://chinallm.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-YOUR_KEY" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Include your API key in the Authorization header:
Authorization: Bearer sk-YOUR_API_KEY
Your API key is found at Console → Tokens. Never share it. You can create multiple keys and revoke them at any time.
All prices per 1 million tokens. Pay only what you use.
| Model | Input | Output | Context | Notes |
|---|---|---|---|---|
| deepseek-chat | $0.27 | $0.54 | 64K | Best Value |
| deepseek-reasoner | $0.55 | $1.00 | 64K | Reasoning model |
| glm-4-flash | $0.01 | $0.01 | 128K | Free trial |
| glm-4.7-flash | $0.01 | $0.01 | 128K | Latest GLM |
More models coming soon: Qwen, Hunyuan, Moonshot, ERNIE.
https://chinallm.dev/v1/chat/completions
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (e.g. deepseek-chat) |
messages | array | Yes | List of messages with role and content |
temperature | number | No | 0-2. Higher = more random. Default varies by model. |
max_tokens | number | No | Max output tokens to generate |
stream | boolean | No | Enable SSE streaming (default: false) |
curl https://chinallm.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-YOUR_KEY" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."}
],
"temperature": 0.7,
"max_tokens": 500
}'
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1700000000,
"model": "deepseek-chat",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing uses quantum bits..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 85,
"total_tokens": 110
}
}
Set "stream": true to receive token-by-token responses via Server-Sent Events (SSE):
// Python example with streaming
import requests, json
response = requests.post(
"https://chinallm.dev/v1/chat/completions",
headers={
"Authorization": "Bearer sk-YOUR_KEY",
"Content-Type": "application/json"
},
json={
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Write a haiku about AI"}],
"stream": true
},
stream=True
)
for line in response.iter_lines():
if line:
line = line.decode("utf-8")
if line.startswith("data: ") and line != "data: [DONE]":
chunk = json.loads(line[6:])
content = chunk["choices"][0].get("delta", {}).get("content", "")
if content:
print(content, end="", flush=True)
| Status | Error | Description |
|---|---|---|
| 401 | invalid_api_key | Missing or invalid API key |
| 402 | insufficient_quota | Account balance too low — top up at Console |
| 429 | rate_limit | Too many requests — slow down |
| 500 | server_error | Internal server error — retry with backoff |
Any library that works with OpenAI's API works with ChinaLLM — just change the base URL:
from openai import OpenAI
client = OpenAI(
api_key="sk-YOUR_KEY",
base_url="https://chinallm.dev/v1"
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello!"}]
)