LLM latency: why your AI feature feels slow and how to cut time to first token
LLM latency is mostly output length, pre-inference work and missing streaming. Where the time goes, which fixes help most, and how to measure time to first token separately.
Your AI feature works, the answers are good, and users still say it feels
slow. LLM latency is rarely one problem. It is a sum of work before the
model is called, the wait for the first token, and the time to generate the
rest, and each part has a different fix. Teams often swap to a faster model
and find the feature feels the same, because the delay was somewhere else.
This post covers where the time goes, the fixes in rough order of payoff, and
how to measure time to first token so you know which one you need. It is
about the domain, not any particular deployment; the sources are vendor
documentation, linked inline.
Where does LLM latency actually come from?
Three places, and only one of them is the model's generation speed:
Pre-inference work. Auth, retrieval, context assembly, prompt
construction and any serial pre-checks. AWS's agentic AI guidance notes
that by the time the first token leaves the model, the agent may already
have used the whole latency budget on work that happens before inference
begins.
Time to first token (TTFT). The delay before the first output reaches
the user.
Generation. The time to produce the remaining tokens, which grows with
the length of the answer.
The diagram is illustrative, not measured: the proportions differ for every
product, which is the point of measuring.
What should you fix first?
OpenAI's latency guide
lists seven principles. The two concrete numbers in it are worth remembering
because they reorder the usual instincts:
Output tokens are the main lever. As a heuristic, cutting 50% of output
tokens may cut about 50% of latency.
Input tokens matter much less. Cutting 50% of the prompt may only improve
latency by 1-5%, and it matters mainly with very large contexts.
Those are the guide's own rules of thumb, not guarantees, so test on your
workload. Still, they suggest this order:
Fix
What it targets
Typical effort
Watch out for
Stream the response
Perceived wait
Low
Tool-call pauses, moderation on streamed text
Ask for shorter output
Generation time
Low
Answers that become too terse to be useful
Trim structured-output syntax
Generation time
Low
Verbose JSON keys and wrappers add tokens
Parallelise independent steps
Pre-inference and multi-call flows
Medium
More concurrent load against rate limits
Combine sequential calls
Round trips
Medium
Larger prompts, harder-to-debug failures
Use a smaller model for easy steps
Generation and TTFT
Medium
Needs an evaluation set to prove quality holds
Skip the LLM where code will do
Everything
Varies
Needs a clear rule for when to bypass
Why does streaming matter more than raw speed?
Users judge a feature by when something starts to happen, not when it ends.
AWS's guidance puts it directly: user-facing agents are judged on perceived
latency, and streaming keeps time to first token short even when total
processing takes several seconds. OpenAI's guide likewise calls showing
progress through streaming and visible steps a main way to make users wait
less.
Two caveats from the same sources:
Streaming does not recover pre-inference time. If retrieval and prompt
assembly take seconds, the first token is late no matter how you deliver
the rest.
Tool calls create silent gaps. When an agent pauses mid-answer to call a
tool, a client with no signal shows partial text followed by a stall. The
baseline fix is to send a visible status the moment a tool-use block
appears and resume streaming afterwards.
If output passes through a moderation or guardrail step, there is a real
trade-off. AWS notes that Bedrock Guardrails' synchronous mode raises
accuracy but also raises TTFT, while asynchronous mode keeps TTFT low at the
risk of emitting text that is later retracted. Decide this per workload by
how costly a bad token is, as with
human-in-the-loop approval steps.
How do you measure time to first token?
Track it as its own metric, not as a footnote to total duration. AWS
recommends two:
Pipeline TTFT: from request arrival to the first output byte reaching
the client. This is the number users feel and the one to put an SLO on.
Model TTFT: from the model call to the first text delta. This isolates
the model and routing behaviour.
When the two diverge, the gap is everything that is not the model: retrieval,
prompt building, guardrails, network. That gap tells you whether a faster
model would help at all. If pipeline TTFT is mostly pre-inference time, the
better investments are narrower retrieval (see
RAG hybrid search and reranking),
parallel pre-checks and warm connections.
Report percentiles, not averages. A p50 that looks fine can hide a p95 that
is the reason people complain, and the slow requests are often the ones with
the longest prompts or the most tool calls.
What do the other levers cost you?
Latency fixes trade against other things, and some interact with work you may
already have done:
Smaller models run faster and cheaper but can lose quality on hard
steps. Prove it with a regression set, as in
LLM evals in CI, before
routing traffic to them.
Prompt caching reduces the input processed on repeat requests. Given
how little input trimming helps latency in typical prompts, think of it as
primarily a cost lever; the full picture is in
LLM prompt caching cost.
Structured output adds tokens through syntax. If you need strict JSON,
keep keys short and the schema lean, and see
structured output reliability
for the retry costs that can erase any gain.
Fallbacks and retries add latency in the failure case. A timeout that
triggers a second model is a latency decision as much as a reliability one;
see LLM API fallback.
Multi-agent chains add each upstream agent's full duration to TTFT if
the user-facing agent waits for all of them. Streaming intermediate results
into the final agent avoids that.
Does the interaction type change the target?
Yes, and the target should be set per interaction rather than as one number:
Interaction
What users tolerate
Where to focus
Chat or assistant
A short wait, then visible streaming
TTFT, streaming
Inline suggestion in an editor or form
Very little; late is useless
Small model, short output, caching
Voice
Far less than text
End-to-end pipeline, interruption handling
Background job or batch
No user-facing TTFT
Throughput and cost, not latency
AWS suggests anchoring targets to user research or published interaction
norms instead of a round number, which is sound advice: ask a few real users
what feels slow before engineering to a figure.
What to do next
Before you change a model or a prompt, do this in order:
Add pipeline TTFT and model TTFT to your tracing, with p50 and p95.
Look at the gap between them. If it is large, fix pre-inference work
first.
Turn on streaming for every user-facing path, and add a visible status for
tool calls.
Cap output length and trim any verbose structured-output syntax.
Only then test a smaller model for the steps where quality allows, using
an evaluation set.
Re-measure after each change, under realistic load.
If you are building an AI product and want latency designed in rather than
patched on after launch complaints, that is the kind of work our
AI SaaS service covers.
Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write
Frequently asked questions
What is time to first token (TTFT)?
It is the delay between a user's request and the first piece of output reaching them. For interactive AI features it is the main signal of how fast the product feels, because streaming lets the rest arrive while the user is already reading.
What reduces LLM latency the most?
Generating fewer output tokens. OpenAI's latency guide gives a heuristic that cutting 50% of output tokens may cut about 50% of latency, while cutting 50% of the prompt may only improve latency by 1-5%. For perceived speed, streaming matters most.
Will a faster model fix a slow AI feature?
Not always. A faster model improves total generation time, but if the delay is in retrieval, prompt assembly or serial pre-checks before the model is called, time to first token barely moves. Measure before swapping models.
Does prompt caching reduce latency?
It reduces the input tokens processed on repeat requests, which helps most with very large prompts. Since shortening input has a small effect on latency in typical prompts, treat caching as mainly a cost lever with some latency upside.
An AI feature SLO needs more than uptime. Which indicators to measure, which to put in a contract, and how to keep a provider outage or a quality drift from becoming your SLA breach.
Adding AI to an existing app does not require a rewrite. How to pick the first feature, put an AI layer beside your legacy system, and keep failures from reaching users.
How to roll out an LLM prompt or model change without surprising users: shadow mode, canary releases and A/B tests, what each answers, what each costs, and the gates between them.