Chat Completions
POST https://routify.bytedance.city/v1/chat/completions
OpenAI-compatible. Drop-in replacement for api.openai.com.
Request
POST /v1/chat/completions
Authorization: Bearer rtf_xxx
Content-Type: application/json
{
"model": "deepseek-v3.2",
"messages": [
{"role": "system", "content": "You are concise."},
{"role": "user", "content": "Capital of France?"}
],
"temperature": 0.3,
"max_tokens": 256,
"stream": false
}Parameters
| Param | Type | Default | Notes |
|---|---|---|---|
model | string | required | Model name (see Models) or routify-auto |
messages | array | required | OpenAI-style messages |
temperature | number | 1 | 0–2, lower = more deterministic |
top_p | number | 1 | Alternative to temperature |
max_tokens | int | model max | Hard cap on completion |
stream | bool | false | SSE streaming |
stop | string | array | null | Stop sequences |
tools | array | — | Function calling (see Quickstart) |
tool_choice | string | object | auto | Force a specific tool |
response_format | object | — | {"type": "json_object"} for JSON mode |
extra_body.routify | object | — | Routify-specific opts (region, task) |
Response
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1747836000,
"model": "deepseek-v3.2",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Paris."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 2,
"total_tokens": 16
},
"routify": {
"channel": "deepseek-official",
"latency_ms": 187,
"cost_usd": 0.0000028
}
}Streaming
Set stream: true. Each line is data: <json> SSE:
data: {"id":"...","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"...","choices":[{"delta":{"content":" world"}}]}
data: [DONE]Errors
| Code | Reason |
|---|---|
| 400 | Invalid request body |
| 401 | Missing / invalid API key |
| 402 | Insufficient balance |
| 403 | Account suspended / model not allowed for tier |
| 429 | Rate limit |
| 500 | Internal error |
| 502 | All upstream channels failed |
| 503 | Maintenance |