Quickstart
This takes about three minutes.
1. Create an account
Section titled “1. Create an account”Sign up in the console and verify your email. Your $0.50 starter credit is added once the email is verified.
2. Create a key
Section titled “2. Create a key”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:
export TOKEN_API_KEY="tkn_..."3. Send a request
Section titled “3. Send a request”Any model from the models page works; this one is fast and cheap.
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."}] }'pip install openaiimport osfrom openai import OpenAI
client = OpenAI(base_url="https://api.thetoken.dev/v1", api_key=os.environ["TOKEN_API_KEY"])
response = client.chat.completions.create( model="zai-org/glm-5.3-flash", messages=[{"role": "user", "content": "Write a haiku about failover."}],)print(response.choices[0].message.content)print(response.usage)npm install openaiimport OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://api.thetoken.dev/v1', apiKey: process.env.TOKEN_API_KEY })
const response = await client.chat.completions.create({ model: 'zai-org/glm-5.3-flash', messages: [{ role: 'user', content: 'Write a haiku about failover.' }],})console.log(response.choices[0].message.content)console.log(response.usage)4. Check the result
Section titled “4. Check the result”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_tokensandusage.completion_tokensare what you are billed for, at the model’s listed price.usage.prompt_tokens_details.cached_tokensshows the input tokens billed at the cached price.completion_tokensincludes the model’s reasoning. Reasoning models may also return their reasoning text inmessage.reasoning_content.modelis 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.
Next steps
Section titled “Next steps”- Stream the reply as it is written: Streaming.
- Use TOKEN from your tools: Claude Code, Cursor, Cline, OpenCode, LangChain.
- What each error means and how to retry: Errors and rate limits.