API reference
Everything the gateway serves, in one place.
Base URL & CORS
| Prefix | Auth | CORS | Purpose |
|---|---|---|---|
| https://api.thairouter.ai/v1 | API key | any origin, no credentials | OpenAI-compatible surface |
| https://api.thairouter.ai/public | none | any origin | Read-only, aggregate catalog data |
| https://api.thairouter.ai/health | none | — | Liveness |
The dashboard, auth and Stripe routes (/dashboard, /api/auth, /admin, /stripe) are session-authenticated for the web app and are not part of the public API.
Chat completions
Create a completion, optionally streamed. Full guide: Chat completions.
| Field | Type | Description |
|---|---|---|
| modelrequired | string | Live ThaiRouter model id. |
| messagesrequired | array | Non-empty chat history. |
| max_tokens | integer | Omitted = full output budget. Clamped to the model cap and context room. |
| reasoning_effort / reasoning | string / object | Thinking level and exclude. See Reasoning. |
| stream | boolean | SSE with a final usage chunk.Default false. |
| … | any | Other OpenAI fields forwarded as-is. See Parameters. |
Responds 200 with a chat completion (plus thairouter.usage_id, thairouter.cost and thairouter.reasoning_effort), or text/event-stream with x-thairouter-usage-id and x-thairouter-reasoning-effort headers. Errors: Errors.
List models
Live models only, OpenAI list shape with context_length, max_output_tokens, pricing, reasoning (levels, default, whether it can be switched off; null if none) and supported_parameters added.
{
"object": "list",
"data": [
{ "id": "thairouter/glm-5.3-flash", "object": "model", "created": 0, "owned_by": "thairouter",
"context_length": 393216, "max_output_tokens": 131072,
"pricing": { "promptPerMillion": 5, "completionPerMillion": 15 },
"reasoning": { "efforts": ["low", "high", "max"], "default": "max", "optional": false },
"supported_parameters": ["max_tokens", "temperature", "top_p", "stop", "seed", "frequency_penalty",
"presence_penalty", "response_format", "stream", "reasoning", "reasoning_effort"] }
]
}Public catalog
Every model, including coming-soon ones, with the full catalog entry (description, tags, benchmarks), all-time aggregate stats and a 7-day performance snapshot. Cached for 60 s.
{
"models": [
{
"id": "thairouter/glm-5.3-flash",
"name": "GLM 5.3 Flash",
"provider": { "id": "zai", "name": "Z.ai", "url": "https://z.ai" },
"status": "live",
"contextLength": 393216,
"maxOutputTokens": 131072,
"pricing": { "promptPerMillion": 5, "completionPerMillion": 15 },
"tags": ["open-weights", "reasoning", "long-context"],
"stats": { "requests": 1234, "tokens": 5678901, "lastUsedAt": "2026-09-10T08:00:00.000Z" },
"perf": {
"windowDays": 7, "requests": 800, "errors": 3, "successRate": 0.996,
"latencyP50Ms": 1450, "latencyP95Ms": 6200, "tokensPerSec": 62.4
}
}
]
}perf is null when a model had no traffic in the window.
Public activity
| Field | Type | Description |
|---|---|---|
| modelrequired | query string | Any catalog id. Unknown ids return 404. |
| days | query integer | 1 to 90.Default 30. |
Daily aggregates across all users. Days with no traffic are filled with zeros. Cached for 5 minutes.
{
"model": "thairouter/glm-5.3-flash",
"days": 30,
"series": [
{ "day": "2026-08-12", "requests": 41, "prompt": 30210, "completion": 12880, "latencyMs": 1390 },
{ "day": "2026-08-13", "requests": 0, "prompt": 0, "completion": 0, "latencyMs": null }
]
}Health
{ "ok": true }GET / returns { "name": "thairouter-api", "ok": true }. Any other unknown path returns 404 with type: "not_found".