API Reference
TokenDock exposes an OpenAI-compatible REST API. If you are already using the OpenAI SDK, the only changes needed are base_url and api_key.
Base URL
Text
https://tokendock.ai/v1
Authentication
Pass your API key as a Bearer token in the Authorization header on every request:
HTTP Header
Authorization: Bearer your-tokendock-api-key
Chat Completions
POST /v1/chat/completions
Generate a response from a model given a list of messages. Compatible with the OpenAI Chat Completions API.
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID to use (e.g. qwen3.6-plus) |
| messages | array | Yes | Array of message objects with role and content |
| max_tokens | integer | No | Maximum number of tokens to generate |
| temperature | number | No | Sampling temperature, 0–2. Default: 1 |
| top_p | number | No | Nucleus sampling probability. Default: 1 |
| stream | boolean | No | If true, responses are streamed as server-sent events |
| stop | string or array | No | Up to 4 stop sequences |
| n | integer | No | Number of completions to generate. Default: 1 |
| user | string | No | Identifier for your end-user (for abuse detection) |
Example request
JSON
{
"model": "qwen3.6-plus",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Summarise the benefits of LLM APIs."}
],
"max_tokens": 512,
"temperature": 0.7
}
Example response
JSON
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1712345678,
"model": "qwen3.6-plus",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "LLM APIs provide scalable access to large language models..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 94,
"total_tokens": 122
}
}
Streaming
Set "stream": true to receive tokens incrementally as server-sent events. Each event is a JSON delta prefixed with data: . The stream ends with data: [DONE].
The OpenAI SDK handles streaming automatically when you pass stream=True (Python) or stream: true (JavaScript).
Error codes
| HTTP status | Meaning |
|---|---|
| 400 | Bad request — missing or invalid parameters |
| 401 | Unauthorized — missing or invalid API key |
| 402 | Payment required — insufficient credit balance |
| 429 | Rate limit exceeded — too many requests |
| 500 | Internal error — retry with exponential back-off |