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
| Method | Path | Description |
|---|---|---|
| POST | /v1/chat/completions | Chat completion (streaming supported) |
| GET | /v1/models | List available models |
| POST | /v1/embeddings | Text embeddings |
| POST | /v1/audio/transcriptions | Speech to text |
| POST | /v1/audio/speech | Text to speech |
| GET | /v1/balance | Account 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"
}
}| Code | Description |
|---|---|
| 401_invalid_api_key | API key missing, malformed or revoked. |
| 402_balance_insufficient | Account balance cannot cover this request. |
| 403_model_not_in_scope | This key is not allowed to call that model. |
| 403_ip_not_whitelisted | Caller IP is outside the key IP whitelist. |
| 429_rate_limit_rpm | Requests-per-minute ceiling reached. |
| 429_rate_limit_tpm | Tokens-per-minute ceiling reached. |
| 400_content_filter | Content blocked by the safety filter. |
Include he_request_id when contacting support — it pins the exact request.