Time to first token and the other LLM latency numbers
Time to first token is the wait before a model's first output token. How it differs from inter-token and end-to-end latency, and where to measure each one.
- Published
- Reading time
- 10 min read
In short
- Time to first token (TTFT) is the wait between sending a request and receiving the first token of output. It covers network time, queueing, and prefill, so it grows with the length of the input.
- Total latency is mostly decode time, which grows with the length of the output. OpenAI's latency guide estimates that halving output tokens cuts latency by about half, while halving the prompt saves only a few percent.
- Track the 95th and 99th percentiles per model and per input-size bucket. An average across all traffic moves whenever users ask longer questions.
- Measure at the client and at the gateway. The difference between the two is network and client time, and the gateway's own split separates its overhead from the provider's.
Time to first token (TTFT) is the time between sending a request to a model and receiving the first token of its answer. NVIDIA's benchmarking docs define it as how long you wait before seeing the model's output, and note that it generally includes request queueing, prefill, and network latency. For a streaming chat interface, it is the number users notice first.
It is one of four LLM latency numbers worth recording. The other three are inter-token latency, end-to-end latency, and throughput. Each one moves for a different reason, and mixing them up is how teams spend a week shortening prompts to fix a problem caused by long answers.
What time to first token measures
Time to first token measures everything that happens before the model emits its first output token: the network trip to the provider, time waiting in the provider's queue, and prefill. Prefill is the pass in which the model reads every input token. Longer prompts take longer to prefill, so TTFT grows with input length.
That last point is what makes TTFT different from the other numbers. NVIDIA's docs state it plainly: longer prompts increase TTFT because attention runs over the full input sequence. A request with 60,000 tokens of retrieved documents will wait longer for its first token than a two-line question to the same model, even if both answers are the same length.
Queueing is the part you control least. When a provider is busy, requests wait for capacity before prefill starts. That wait shows up as TTFT, not as an error, so a provider under load often looks slow before it looks broken.
The four LLM latency numbers
Record four numbers for every model call: time to first token, inter-token latency, end-to-end latency, and output tokens per second. Each answers a different question, and none of them can be derived from an average of the others.
| Number | What it measures | Driven mostly by |
|---|---|---|
| Time to first token | Wait until the first output token | Queueing, network, input length |
| Inter-token latency | Average gap between consecutive output tokens | Model size, provider load |
| End-to-end latency | Request sent to last token received | Output length |
| Tokens per second | Output tokens divided by decode time | Model size, provider load |
NVIDIA gives the relationships. End-to-end latency is TTFT plus generation time. Inter-token latency, also called time per output token, is the generation time divided by the number of output tokens after the first one.
The formula explains a rule in OpenAI's latency guide. Output tokens dominate total time, so "cutting 50% of your output tokens may cut ~50% of your latency," while cutting half the prompt "may only result in a 1–5% latency improvement." Input length moves TTFT. Output length moves everything else.
Which number your users feel
Users of a streaming chat interface feel time to first token, then the pace of the stream. Users of anything that waits for a full response, such as a form fill, a classification step, or an agent's tool call, feel end-to-end latency. Pick the target that matches how the output is consumed.
For chat, set the objective on TTFT. Jakob Nielsen's usability research puts the limit for an uninterrupted flow of thought at about one second. A first token inside that window reads as a responsive product, and a smooth stream after it keeps the wait tolerable even when the full answer takes ten seconds.
For agents, set it on end-to-end time per step and per run. An agent step that returns a tool call is never streamed to a person, so a fast first token buys nothing. What matters there is how long the whole run takes, which the agent observability article covers.
Why an average hides the problem
An average of LLM latency mixes short and long prompts, short and long answers, and several models into one number that describes none of them. Use percentiles instead, and split them by the dimensions that drive each metric. The 95th and 99th percentiles show the requests that generate complaints.
Split time to first token by model and by input-size bucket. Without the bucket, a feature launch that adds retrieved documents to every prompt looks like a provider slowdown. With it, you see that TTFT for short prompts is unchanged and a new long-prompt bucket appeared.
Split end-to-end latency by output-size bucket for the same reason. Then add three filters:
- Successful responses only. OpenTelemetry's server-side TTFT metric is defined for successful responses, and timeouts belong in an error rate, not a latency chart.
- Streaming and non-streaming apart. A non-streaming request has no meaningful first token from the client's point of view.
- Cache hits apart. A request served from a semantic cache returns in milliseconds and pulls every percentile down.
Where to measure, and what the gaps tell you
Measure latency at the client, at the gateway, and as the provider reports it. Each point includes a different set of delays, so the differences between them locate a problem. A single measurement tells you that something is slow but not where.
| Measured at | Includes | A gap here means |
|---|---|---|
| Client | Everything the user waits for | Client minus gateway: network to your gateway, client parsing, rendering |
| Gateway | Gateway work plus the provider call | Gateway minus upstream: the gateway's own overhead |
| Upstream call | Network to the provider, queue, prefill, decode | High upstream TTFT: provider load or a long prompt |
OpenTelemetry's GenAI conventions name both ends. On the server side, gen_ai.server.time_to_first_token and gen_ai.server.time_per_output_token are histograms in seconds. On the client side, the names use "chunk" instead of "token": gen_ai.client.inference.time_to_first_chunk and gen_ai.client.inference.time_per_output_chunk, plus a gen_ai.response.time_to_first_chunk span attribute. All of them are marked as in development, so pin your instrumentation version, as the observability article recommends.
A chunk is not always one token. Providers batch several tokens into one streamed event, so client-side inter-chunk timing understates the token rate. Compare like with like.
Gateway overhead versus upstream time
A gateway sits on the request path, so it should report how much of the latency is its own. The useful split is upstream time, spent waiting on the provider, against overhead, spent in the gateway's parsing, routing, plugins, and key selection. Without that split, every slow request becomes an argument between teams.
Bifrost, an open-source AI gateway by Maxim AI, records the split on every request. It exposes Prometheus histograms for the three numbers this article cares about: bifrost_stream_first_token_latency_seconds, bifrost_stream_inter_token_latency_seconds, and bifrost_upstream_latency_seconds. Each carries labels for provider, model, virtual key, team, and the routing rule that chose the target, so a TTFT regression can be traced to one provider or one rule.
Its traces carry two first-token numbers. bifrost.response.time_to_first_token_ms runs from the moment Bifrost received the request to the first chunk, including queueing and plugin time. gen_ai.response.time_to_first_chunk runs from the start of the provider stream to the first chunk. The difference between them is time spent inside the gateway. The latency breakdown in the log view goes one level further and divides overhead into named buckets such as serialization, plugins, key selection, and queue wait.
That pair of numbers is the main reason to measure at a gateway rather than only in the client. It answers the first question in any latency incident: is the provider slow, or is something in front of it slow?
What lowers time to first token
Time to first token falls when the model has less to read, when it can skip reading what it has seen before, and when the request waits less before it starts. The levers below are in rough order of how often they help in production.
- Send fewer input tokens. Trim retrieved documents, tool definitions, and history. The context engineering article covers what to cut.
- Cache the prefix. Prompt caching lets the provider skip prefill for a repeated prefix. Anthropic reported a 100,000-token cached prompt dropping from 11.5 seconds to 2.4 seconds to first token. The prompt caching article explains how to keep the prefix stable.
- Stream the response. Streaming does not change when the first token is generated, but without it the user waits for the last one.
- Use a smaller model for the first step. A fast model can acknowledge, classify, or route while a larger one works.
- Run pre-steps in parallel. Retrieval, input guardrails, and moderation that run in sequence before the model call add directly to TTFT. The guardrails article weighs which checks need to block.
- Call a nearer region. Network round trips are small next to prefill, but they are paid on every request.
Set a TTFT timeout and fail over
Give streaming requests a separate timeout for the first token, shorter than the total request timeout. A stream that has produced nothing after several times its normal TTFT is usually stuck in a queue, and moving it to another provider is faster than waiting. A total timeout alone cannot tell a stuck request from a long answer.
Bifrost supports this in its routing rules. For streaming requests, ttft_timeout_ms sets how long an attempt may wait for its first token before Bifrost moves to the next fallback, and the last fallback is never cut off by the timeout. The LLM routing article covers how to order those fallbacks.
Set the timeout from your own 99th percentile for each input-size bucket, not from a round number. A timeout below the normal TTFT for long prompts sends healthy requests to the fallback, doubles their cost, and makes the long-prompt bucket slower.
Frequently asked questions
What is a good time to first token?
For interactive chat, aim for a 95th percentile under about one second. That matches Jakob Nielsen's limit for keeping a user's train of thought. There is no universal number: TTFT depends on the model, the provider's load, and the length of your prompt. Set the target per input-size bucket, because a 50,000-token prompt cannot meet the same target as a short question.
What is the difference between time to first token and latency?
Time to first token is the wait until the first output token arrives. Latency usually means end-to-end latency, the wait until the last token arrives. End-to-end latency equals TTFT plus decode time, and decode time grows with the number of output tokens. A long answer can have a fast TTFT and a slow end-to-end latency.
Why is my time to first token high?
The usual causes are a long prompt, a busy provider, and slow steps before the model call. Check input token counts first, because prefill time grows with input length. Then compare upstream TTFT across providers to spot queueing. Finally, check whether retrieval or guardrail checks run in sequence before the request is sent.
Does prompt caching reduce time to first token?
Yes, when a long prefix repeats. The provider skips prefill for the cached part, which is where most of the TTFT for long prompts goes. Anthropic reported a 79 percent drop in TTFT for a 100,000-token cached prompt. A cache miss, such as a changed system prompt, removes the benefit, so monitor the cache hit rate alongside TTFT.
What is inter-token latency?
Inter-token latency is the average time between consecutive output tokens after the first one. It is also called time per output token. It is computed as the decode time divided by the number of output tokens minus one. It sets the pace of a stream: a high value makes text appear in slow bursts even when the first token arrived quickly.
Does streaming reduce LLM latency?
Streaming does not make the model finish sooner. It reduces perceived latency, because the user starts reading at the first token instead of waiting for the last. For output that is consumed whole, such as JSON passed to code, streaming adds parsing work and gives no benefit. Use it where a person reads the output as it arrives.
Sources
- 01MetricsNVIDIA NIM docs
- 02Semantic conventions for generative AI metricsGitHub, OpenTelemetry
- 03Client inferenceGitHub, OpenTelemetry
- 04Latency optimizationOpenAI API docs
- 05Prompt caching with ClaudeClaude blog
- 06Response Times: The 3 Important LimitsNielsen Norman Group
- 07Prometheus metricsBifrost docs
- 08Latency breakdownBifrost docs