tokrouterdocs
API reference

Chat Completions

Request fields, response shape and streaming behaviour for POST /v1/chat/completions.

.mdOpen in Claude
POST https://api.tokrouter.dev/v1/chat/completions
Authorization: Bearer sk-…
Content-Type: application/json

The most universal entry point: OpenAI protocol, and the default path for most clients and frameworks.

Request fields

FieldTypeRequiredNotes
modelstringYesModel id, see Models
messagesarrayYesItems have role (system / user / assistant / tool) and content
streambooleanNotrue returns SSE, see Streaming
max_tokensintegerNoOutput token cap
temperaturenumberNoSampling temperature
top_pnumberNoNucleus sampling
stopstring / arrayNoStop sequences
toolsarrayNoFunction declarations, see Tool calling
tool_choicestring / objectNoauto / none / a named function
response_formatobjectNoStructured output, see Structured output
userstringNoCaller-defined end-user identifier

A subset of the OpenAI protocol

The gateway interprets requests as OpenAI Chat Completions and maps them to the target vendor. Vendor-exclusive fields are not guaranteed — see Protocol bridging.

Response

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1793000000,
  "model": "gpt-5.4-mini",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "Hello"},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 3,
    "total_tokens": 15
  }
}

usage.prompt_tokens_details.cached_tokens (when present) corresponds to the cache-read billed portion.

Streaming

With stream: true each chunk carries choices[0].delta and the stream ends with data: [DONE]. usage usually appears only in the final chunk, and some upstreams omit it entirely.

Status codes

StatusMeaning
200Success (streaming also starts with 200; errors after the stream opens arrive as events)
400Invalid body, e.g. unknown model
401Authentication failure, see Authentication
429Rate limit or quota cap
5xxUpstream vendor error

Specific type / code values come from the upstream and are not enumerated here.