页面简介
Time to first token (TTFT) is how long an LLM takes to start answering. See where the clock starts, why reasoning models hide it, and how to reduce it.
正文摘录
Back to AI InferenceTime to first token (TTFT): what it measures and how to reduce itInferencePublished 13 Nov 2026Your dashboard says 300 ms, but users still wait. Here’s what time to first token really measures, how to time it yourself, and the fixes that bring it down.By Eli MogulContent Writer & EditorTakeawaysUsers judge speed by when words first appear. Once streaming outpaces reading, quicker tokens go unnoticed.Self-measured numbers usually exceed what a host's metrics show, because your timer includes network time the server never sees.Reasoning models often think before they speak, so an early first token can still precede a long silence.TTFT shifts as inputs grow and servers get busier, so give short and long requests different goals.Trimming input, keeping prompts cache-friendly, and dialing back reasoning are the quickest fixes on your end.What is time to first token (TTFT)?Time to first token is how long you wait before an LLM starts answering. It's the number that decides whether a chat window feels instant or stuck.You've probably lived this: the demo felt snappy on short test prompts, then real users pasted in long documents and replies started to crawl. For a refresher on what happens inside a model during a request, start with what AI inference is.What fills the wait: network, queue, and prefillThree things fill the time to first token: the network trip, the provider's queue, and prefill. TTFT, also called first token latency, ends when the first token lands, not the last, because LLM responses stream one token at a time.Network: your request travels from your code to the provider, through DNS, a TLS handshake, and usually a gateway or load balancer.Queue: if the server is busy, your request waits behind everyone else's.Prefill: the model reads your entire prompt and builds its KV cache (the stored attention values it reuses for every new token) before it can produce anything. Longer prompts mean longer prefill.TTFT vs TPOT, ITL, and end-to-end latencyTTFT is one of four numbers that describe a streamed response, and each answers a different question.MetricWhat it measuresWhat it decidesTime to first token (TTFT)Request sent to first token receivedHow fast the reply seems to startTime per output token (TPOT), also called inter-token latency (ITL)Average gap between tokens after the firstHow smoothly the reply streamsEnd-to-end latencyRequest sent to last token receivedWhen the full answer is readyTokens per second (TPS)Output tokens per second, per user or across a serverThroughput and costDefinitions follow vLLM's metrics docs and NVIDIA's NIM benchmarking guide.TPOT and ITL describe the same thing. Most tools calculate it as end-to-end latency minus TTFT, divided by output tokens minus one, though some fold the first token into the average, so check before you compare numbers from two tools.TTFT gets the attention for a reason. The DistServe researchers point out that once tokens arrive faster than people read (about 250 words per minute), faster streaming stops mattering. The wait before the first word is the part users actually feel.One caution: a provider can lead a TTFT chart and still finish answers last, so always check end-to-end latency alongside it.How to measure time to first tokenYour TTFT, your provider's dashboard, and a benchmark chart can all disagree about the same request, because each one starts or stops the clock somewhere different.TTFT clock diagramYour clock vs the server's clockYour clock and the server's clock measure TTFT from different starting points. Picture one streamed chat request with five timestamps:Your code sends the request.The server receives it and starts tokenizing.The first streamed chunk with any token arrives.The first chunk with answer text arrives.The last token arrives.Your TTFT is 3 minus 1. The server's TTFT is 3 minus 2. Time to first answer token (TTFA) is 4 minus 1, and end-to-end latency is 5 minus 1.vLLM, the most common open-source serving engine, starts its TTFT clock when its frontend receives the request and tokenization begins. Everything before that (DNS, TLS, the trip across the internet, a load balancer, an API gateway) sits in your number and nowhere on the server's dashboard.That's how a dashboard can say 300 ms while your users complain. The gap isn't a measurement error. It's real time your user spends waiting.Why the first chunk can be emptyThe first streamed chunk is often empty because many APIs open with a chunk that carries only a role or metadata. NVIDIA's benchmarking tool skips responses with no content for exactly this reason: a TTFT stopped on an empty chunk measures nothing. Your timer should skip them too.How to time TTFT and TTFA in codeTo time TTFT and TTFA in code, run two clocks on the same stream: stop the first on any non-empty chunk, thinking included, and the second on the first chunk with real answer text.This snippet works with any OpenAI-compatible endpoint. Providers name the reasoning field differently, so it checks the two common ones.import os import time from openai import OpenAI client = OpenAI(base_url=os.environ["BASE_URL"], api_key=os.environ["API_KEY"]) start = time.perf_counter() ttft = ttfa = None stream = client.chat.completions.create( model=os.environ["MODEL"], messages=[{"role": "user", "content": "Explain what a SIP trunk is in two sentences."}], stream=True, ) for chunk in stream: if not chunk.choices: continue delta = chunk.choices[0].delta thinking = getattr(delta, "reasoning_content", None) or getattr(delta, "reasoning", None) answer = delta.content now = time.perf_counter() if ttft is None and (thinking or answer): ttft = now - start # first token of any kind if ttfa is None and answer and answer.strip(): ttfa = now - start # first token of the answer end = time.perf_counter() def show(seconds): return f"{seconds:.3f}s" if seconds is not None else "none" print(f"TTFT {show(ttft)} TTFA {show(ttfa)} end-to-end {show(end - start)}")One run tells you very little. Repeat it and record p50 (the median) and p95 (the time 95% of requests beat), along with the prompt size and the region you ran from.Time to first answer token: TTFT for reasoning modelsWith a reasoning model, a fast TTFT can hide a slow answer: the first token is usually the model thinking, and your user sees nothing until the answer starts.In a benchmark Telnyx ran and published on GitHub, GLM 5.3 with reasoning set to high answered 230 requests across four providers. The first streamed piece was reasoning text in 153 of them, about two-thirds. With a 10,000-token prompt and a long answer, the median first token arrived after 1.18 seconds, but the first word of the answer took 9.18 seconds.A TTFT chart would call that request fast. Treat these results as directional: one model, one or two days of runs, and ten requests per provider per prompt size, pooled across providers.Time to first answer token is the fix. Artificial Analysis defines it as the wait until the first answer token, with reasoning time included, so reasoning and non-reasoning models get measured the same way. Report it next to TTFT for any reasoning model.If users never see the thinking, TTFA is the wait they feel. If you show a "thinking" indicator, TTFT still matters, since it's the moment that indicator can appear.Your biggest TTFA lever is reasoning effort: lower it, or turn reasoning off, for routine requests.Why TTFT is a range, not a numberTTFT changes with prompt size and with how busy the server is, so a single TTFT figure tells you little until you know both.How prompt size changes TTFTPrompt size changes TTFT a lot, though not in a straight line. In the same Telnyx benchmark, short answers only, median TTFT was 0.44 seconds at about 900 prompt tokens, 1.00 second at about 9,500, and 4.77 seconds at about 89,000.Ten times the prompt cost a little over double the wait at the small end and almost five times at the large end. On short prompts, fixed costs like the network and the queue dominate. On long ones, prefill takes over.How load changes TTFTLoad roughly doubles TTFT, and long prompts pay the most in absolute terms. In a second Telnyx benchmark (GLM 5.3 Flash on two managed endpoints, October 2026), running ten requests at once instead of one moved median time to first answer like this:1,000-token prompt: 0.34 to 0.55 seconds10,000-token prompt: 0.72 to 1.47 seconds100,000-token prompt: 4.16 to 8.76 secondsPrefill is the work queued requests wait on, so the longer the prompt, the bigger the penalty.TTFT under current loadHow to set a TTFT targetSet a TTFT target per prompt-size band, and judge it at the slow end, not the median. Users remember the worst waits, which is why benchmark bodies use p99 limits (the time 99 of 100 requests must beat).MLPerf, the industry inference benchmark, shows how much the job matters. Its original Llama 2 70B chat test allowed 2 seconds of TTFT, its interactive chat test set a 450 ms p99 limit, and its long-context Llama 3.1 405B test allowed 6 seconds at p99.One number for everything doesn't work either. Researchers behind the Etalon framework note that TTFT ignores prompt length, so a single fixed target isn't practical, and dividing TTFT by prompt length unfairly punishes short requests. A single TTFT number is close to useless until you know the prompt size.How to reduce time to first tokenMost TTFT fixes are yours to make: send less, send it closer, and ask for less thinking. The rest depends on how your provider runs its servers.What you can changeYou can reduce TTFT on your side with six changes:Send a shorter prompt. Trim retrieved context, old conversation turns, and tool definitions the model won't use.Make the prompt cacheable. A cached prefix is the unchanged tokens at the start of a prompt, so one changed character early on breaks it. Put fixed instructions first and per-user content last. Check your provider's minimum, too: OpenAI's guide sets a 1,024-token floor and notes caching doesn't guarantee