thairouter
Overview

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.

SettingValue
Base URLhttps://api.thairouter.ai/v1
Auth headerAuthorization: Bearer sk-tr-…
Live modelthairouter/glm-5.3-flash
BillingPer 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

  1. Sign in at thairouter.ai/dashboard with Google, GitHub or email.
  2. Open Credits and top up. New requests are refused with 402 when the balance can't cover the reservation.
  3. 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": "สวัสดี แนะนำตัวหน่อย"}]
  }'
Add "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.

200 OK
{
  "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 }
}

Where to go next