# Quickstart

FasterTokens is an OpenAI-compatible chat completions endpoint for voice agents. For every request it queries multiple inference providers simultaneously and optimizes for time to first token. You change a base URL and a key; your prompts, tools and streaming code stay as they are.

## 1. Create an API key

[Sign up](https://fastertokens.com/signup), open **API keys** in the dashboard and create a key. It starts with `ft_live_` and is shown once. Keep it on your server:

```bash
export FASTERTOKENS_API_KEY=ft_live_…
```

## 2. Send a turn

```bash
curl https://api.fastertokens.com/v1/chat/completions \
  -H "Authorization: Bearer $FASTERTOKENS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Session-Id: call-8841" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "stream": true,
    "messages": [
      {"role": "system", "content": "You are a phone assistant. Reply in one short sentence."},
      {"role": "user", "content": "Hello?"}
    ]
  }'
```

The response is the standard stream of `chat.completion.chunk` events ending in `data: [DONE]`.

## 3. Use it from an OpenAI SDK

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.fastertokens.com/v1", api_key=os.environ["FASTERTOKENS_API_KEY"])

stream = client.chat.completions.create(
    model="deepseek-v4.1-flash",
    messages=messages,
    tools=tools,
    stream=True,
    extra_headers={"X-Session-Id": call_id},
)
for chunk in stream:
    delta = chunk.choices[0].delta if chunk.choices else None
    if delta and delta.content:
        speak(delta.content)
```

```ts
import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://api.fastertokens.com/v1', apiKey: process.env.FASTERTOKENS_API_KEY });

const stream = await client.chat.completions.create(
  { model: 'deepseek-v4.1-flash', messages, tools, stream: true },
  { headers: { 'X-Session-Id': callId } },
);
```

## Send one session ID per call

Set the `X-Session-Id` header (or the `user` field) to an ID that stays the same for every turn of a call and differs between calls. The turns of a call are then served consistently, and later turns can reuse the cached prompt. Without it, every turn is treated as a new call.

## What to expect

- **Time to first token.** Every response carries `x-ttft-ms`: the time from your request reaching the endpoint to the first real output leaving it. Live percentiles are on the [benchmark page](https://fastertokens.com/benchmark).
- **Fail fast.** If no output is produced within 2 seconds, the request ends with HTTP 504 (`first_token_timeout`) before any stream starts, so your agent's fallback model can take the turn. You can change the deadline per request with `X-First-Token-Deadline-Ms` (300 to 10,000).
- **Sized for speech.** Reasoning is off. `max_tokens` defaults to 500 and is capped at 2,000.
- **Preview limits.** The preview is free. Each account has a monthly allowance of completions, shown in the dashboard; write to us if you need more.

Next: [voice agent setup](https://fastertokens.com/docs/voice-agents) and the [API reference](https://fastertokens.com/docs/api-reference).
