Skip to content
47% off: the complete course for $79 (reg. $149)Order now →
AI Builder

AI builder glossary

Time to first token (TTFT)

The delay between sending a request and receiving the first token of output, the latency number that most shapes how fast an AI feature feels.

Time to first token measures how long the user stares at nothing. With streaming, once the first token arrives the response starts appearing, so TTFT often matters more to perceived speed than total generation time. It is distinct from output speed (tokens per second after the stream starts) and from end-to-end latency.

Several things drive it: the size of the input the model must process, the model you chose, provider load and region, and, on reasoning models, thinking, which happens before any visible answer text. Your own code adds to it too, through retrieval, database lookups, and other calls you run before the model call even starts.

To cut it, measure each stage first. Common fixes include prompt caching for long stable prefixes, smaller or faster models for latency-sensitive routes, lower effort, trimming context, running retrieval in parallel with other setup work, and starting the stream before slow, non-essential work finishes. Showing an immediate status in the interface helps perception even when the number can't drop further.

Track TTFT per route as a percentile, not an average; the slow tail is what users remember and what complaints are about.

Example

A search-answer feature has a slow TTFT. Tracing shows half the delay is a sequential embedding call and database query, so the team runs them in parallel with loading the user's settings and caches the long system prompt.

Learn more in the course

Related terms

Go from definitions to doing

Learn to build AI-powered apps in 132 practical lessons.