Services

Resources

Company

/

Time to first token

TTFT (time to first token)

Time to first token (TTFT) is the time between sending a request to a large language model (LLM) and receiving the first token of its response. It measures how long a user waits before a streamed answer starts to appear. Most of it is the prefill phase, when the model processes the whole prompt before generating output.

How to calculate it

Record the timestamp when the request is sent and the timestamp when the first streamed token arrives, then subtract. Total response time is roughly TTFT plus output tokens divided by the generation rate. For example, a TTFT of 400 ms and 500 output tokens at 50 tokens per second gives about 10.4 seconds in total. Some instrumentation libraries emit it as gen_ai.server.time_to_first_token. Track it as a p95 per model.

Why it matters in production

TTFT is the first latency a chat user feels, separate from how long the full answer takes. Longer prompts and lost prompt cache hits push it up. A rising TTFT with flat output length points at prompt growth or a slower provider rather than your own code.

See also

On the One2N blog

References

  1. OpenTelemetry GenAI semantic conventions

Time bar for time to first token. The formula reads total ≈ TTFT + output tokens ÷ tokens per second, worked as 400 ms + 500 ÷ 50 = 10.4 s. The first bar shows a short navy prefill of 400 ms, the TTFT, then a long green decode of 500 tokens at 50 per second, ending at 10.4 s. A second bar for a longer prompt has a much longer red prefill, so the first token arrives later and the whole answer ends later.

Putting this into practice?

Talk to One2N about our AI engineering services

Talk to One2N about our AI engineering services