Skip to content
StatusGet API key

Quickstart

This takes about three minutes.

Sign up in the console and verify your email. Your $0.50 starter credit is added once the email is verified.

In the console, go to API Keys → Create and copy the key. It starts with tkn_ (older keys start with sk- or thetoken_ and keep working). The key is shown only once: TOKEN stores only a hash of it. If you lose it, use Rotate key to get a new one (the old key stops working).

Keep the key in an environment variable. Every sample in these docs reads TOKEN_API_KEY:

Terminal window
export TOKEN_API_KEY="tkn_..."

Any model from the models page works; this one is fast and cheap.

Terminal window
curl https://api.thetoken.dev/v1/chat/completions \
-H "Authorization: Bearer $TOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org/glm-5.3-flash",
"messages": [{"role": "user", "content": "Write a haiku about failover."}]
}'

The response looks like this (the text, IDs and token counts differ on every call):

{
"id": "chatcmpl-0c5d2a7e9b",
"object": "chat.completion",
"created": 1761379200,
"model": "zai-org/glm-5.3-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "One road closes down,\nthe next one is already lit:\nthe message arrives."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 16,
"completion_tokens": 412,
"total_tokens": 428,
"prompt_tokens_details": { "cached_tokens": 0 }
}
}
  • usage.prompt_tokens and usage.completion_tokens are what you are billed for, at the model’s listed price. usage.prompt_tokens_details.cached_tokens shows the input tokens billed at the cached price.
  • completion_tokens includes the model’s reasoning. Reasoning models may also return their reasoning text in message.reasoning_content.
  • model is the name reported by the provider that answered; its spelling can differ from the name you sent. Billing and the console use the name you sent.
  • The console’s Usage Logs show the cost of every request.