API Reference

One OpenAI-compatible API for Qwen, DeepSeek, Doubao, ERNIE, GLM and Kimi.

Quickstart

Create an API key in the console, then point any OpenAI-compatible client at the base URL below.

Base URL

https://api.he-api.com/v1

curl https://api.he-api.com/v1/chat/completions \
  -H "Authorization: Bearer $HE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "qwen-max",
  "messages": [
    { "role": "user", "content": "你好" }
  ]
}'

Authentication

Every request carries your key in the Authorization header. Keys are created and revoked in the console; a revoked key fails immediately.

Authorization: Bearer $HE_API_KEY

Never ship a key in browser code — call from your server.

Endpoints

MethodPathDescription
POST/v1/chat/completionsChat completion (streaming supported)
GET/v1/modelsList available models
POST/v1/embeddingsText embeddings
POST/v1/audio/transcriptionsSpeech to text
POST/v1/audio/speechText to speech
GET/v1/balanceAccount balance

Streaming

Set "stream": true to receive server-sent events. Each frame is a data: line; the stream ends with data: [DONE].

data: {"choices":[{"delta":{"content":"你"}}]}
data: {"choices":[{"delta":{"content":"好"}}]}
data: [DONE]

Errors

Errors return an OpenAI-compatible envelope. Read error.code — it is stable; the message is not.

{
  "error": {
    "code": "401_invalid_api_key",
    "message": "Invalid API key.",
    "type": "invalid_request_error",
    "he_request_id": "req_5d873b805a8e"
  }
}
CodeDescription
401_invalid_api_keyAPI key missing, malformed or revoked.
402_balance_insufficientAccount balance cannot cover this request.
403_model_not_in_scopeThis key is not allowed to call that model.
403_ip_not_whitelistedCaller IP is outside the key IP whitelist.
429_rate_limit_rpmRequests-per-minute ceiling reached.
429_rate_limit_tpmTokens-per-minute ceiling reached.
400_content_filterContent blocked by the safety filter.

Include he_request_id when contacting support — it pins the exact request.