Home Docs Console

API Documentation

Access DeepSeek, GLM, and China's top AI models through one OpenAI-compatible API.

On this page:

Quick Start

  1. Register at chinallm.dev/console
  2. Create an API key in the Tokens tab — starts with sk-
  3. Top up $5+ USDT to start making API calls
  4. Use the key in any OpenAI-compatible client:
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!"}]
  }'

Authentication

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.

⚠️ Rate Limits
Each API key is subject to your account's rate limits. Heavy usage may trigger temporary throttling.

Models & Pricing

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.

Chat Completions

POST
https://chinallm.dev/v1/chat/completions

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. deepseek-chat)
messagesarrayYesList of messages with role and content
temperaturenumberNo0-2. Higher = more random. Default varies by model.
max_tokensnumberNoMax output tokens to generate
streambooleanNoEnable 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
  }'

Response

{
  "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
  }
}

Streaming

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)

Error Codes

StatusErrorDescription
401invalid_api_keyMissing or invalid API key
402insufficient_quotaAccount balance too low — top up at Console
429rate_limitToo many requests — slow down
500server_errorInternal server error — retry with backoff
🔗 OpenAI SDK Compatible

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!"}]
)