/
Log in Create Account

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

ParameterTypeRequiredDescription
modelstringYesModel ID to use (e.g. qwen3.6-plus)
messagesarrayYesArray of message objects with role and content
max_tokensintegerNoMaximum number of tokens to generate
temperaturenumberNoSampling temperature, 0–2. Default: 1
top_pnumberNoNucleus sampling probability. Default: 1
streambooleanNoIf true, responses are streamed as server-sent events
stopstring or arrayNoUp to 4 stop sequences
nintegerNoNumber of completions to generate. Default: 1
userstringNoIdentifier 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 statusMeaning
400Bad request — missing or invalid parameters
401Unauthorized — missing or invalid API key
402Payment required — insufficient credit balance
429Rate limit exceeded — too many requests
500Internal error — retry with exponential back-off