Quickstart
Get started with ThaiRouter.
ThaiRouter is an OpenAI-compatible LLM API that never trains on your data, never shares it with a third party and never stores your prompts. If your code already talks to OpenAI, it already talks to ThaiRouter: change the base URL and the key.
| Setting | Value |
|---|---|
| Base URL | https://api.thairouter.ai/v1 |
| Auth header | Authorization: Bearer sk-tr-… |
| Live model | thairouter/glm-5.3-flash |
| Billing | Per token, in credits (1 credit = ฿1). Reserved up front, settled on real usage. |
How it works
Your request goes from your client to our Cloudflare Worker, which checks the key, reserves credits, and proxies the body in memory to a vLLM server we operate. The response streams straight back. Nothing about the prompt or the answer is written anywhere; we keep token counts and status so the usage page adds up. See Privacy & logging for the exact columns.
1. Get an API key
- Sign in at thairouter.ai/dashboard with Google, GitHub or email.
- Open Credits and top up. New requests are refused with
402when the balance can't cover the reservation. - Open API Keys, create a key and copy it. It starts with
sk-tr-and is shown exactly once; we store only a hash.
2. Make a request
Export the key as THAIROUTER_KEY and send a chat completion.
curl https://api.thairouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THAIROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "thairouter/glm-5.3-flash",
"messages": [{"role": "user", "content": "สวัสดี แนะนำตัวหน่อย"}]
}'"stream": true to receive server-sent events as tokens are produced. See Streaming.3. Read the response
The body is a standard OpenAI chat completion. Two things are ThaiRouter-specific: model echoes the ThaiRouter id you sent (not the upstream name), and a thairouter object carries the usage id and the cost in credits so you can reconcile against your logs.
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "thairouter/glm-5.3-flash",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "สวัสดีครับ ผมคือ…" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 18, "completion_tokens": 42, "total_tokens": 60 },
"thairouter": { "usage_id": "3f1c…", "cost": 0.00072 }
}