# Quickstart

> Create an account and a key, then make your first TOKEN request in curl, Python or TypeScript.

This takes about three minutes.

## 1. Create an account

Sign up in the [console](https://app.thetoken.dev/sign-up) and verify your
email. Your $0.50 starter credit is added once the email is verified.

## 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`:

```bash
export TOKEN_API_KEY="tkn_..."
```

## 3. Send a request

Any model from the [models page](https://thetoken.dev/models/) works; this one is fast and cheap.

**curl**

```bash
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."}]
  }'
```

**Python**

```bash
pip install openai
```

```python
import os
from 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)
```

**TypeScript**

```bash
npm install openai
```

```ts
import 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

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

```json
{
  "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](https://thetoken.dev/pricing/).
  `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.

## Next steps

- Stream the reply as it is written: [Streaming](https://thetoken.dev/docs/features/streaming/).
- Use TOKEN from your tools: [Claude Code](https://thetoken.dev/docs/guides/claude-code/),
  [Cursor](https://thetoken.dev/docs/guides/cursor/), [Cline](https://thetoken.dev/docs/guides/cline/),
  [OpenCode](https://thetoken.dev/docs/guides/opencode/), [LangChain](https://thetoken.dev/docs/guides/langchain/).
- What each error means and how to retry: [Errors and rate limits](https://thetoken.dev/docs/errors/).
