esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

How Do You Design for Low Latency?

How to cut the wait in an LLM app: what to measure, how streaming, caching and fewer steps help, and what each one costs, for your AI interview.

In short

Measure where the wait goes first. Then cut it in four places: stream the reply so words appear early, keep the prompt short and cacheable, remove calls that run one after another, and skip the model when code already knows the answer.

13 min readIntermediateCommon · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Low latency means the user waits as little as possible. First I measure where the wait goes: the time to the first word, and the full time to a finished answer. Then I cut it in four places. I stream the reply so words appear early. I keep the prompt short, with the stable part first, so caching works. I remove model and tool calls that run one after another, and I skip the model when code already knows the answer. Each change gets replayed on real conversations, so I can see whether quality drops.

What is low latency, in plain words?

Latency is the time between asking and getting an answer. Low latency means the user waits as little as possible. The model is only one part of that wait. The request also passes through your code, your search and database, and back to the screen.

Two numbers matter most. A token is a small chunk of text the model reads or writes, often a word or part of one. Time to first token is how long until the first word appears. End-to-end latency is how long until the whole answer is finished. Users feel the first one most, because a blank box looks broken.

Think of a call centre. A caller accepts a short, clear answer, but not a long silence before anyone speaks. The silence is the time to first token. A card-support assistant at a mid-size bank has the same problem: the customer stares at a blank box while several calls run one after another.

Key words

Time to first token (TTFT)
The wait before the first word of the reply arrives on screen.
End-to-end latency
The whole wait, from the user's click to the finished answer.
Streaming
Sending the reply in small pieces while the model is still writing.
Tool call
When the model asks your code to fetch or do something, such as a lookup. Your code runs it.
p95
The wait that 95 out of 100 requests beat. It shows the slow tail that averages hide.

Where does the wait go, and how do you measure it?

Do not guess and swap the model. Find the slow stage first. Time each part of the turn: the request reaching your server, retrieval, each model call, each tool call, and the moment the screen shows text. OpenAI's latency guide gives the same advice.

  • “Measure where users wait before changing the model or prompt.”

    OpenAI

  • “Each sequential model or tool call adds another wait.”

    OpenAI

  1. 1

    Stamp each stage

    Log the time when the request arrives, after retrieval, after each model call and after each tool call.

  2. 2

    Check when text shows

    Measure the moment the screen displays text, not the moment your server sends it.

  3. 3

    Read the slow tail

    Look at the typical request and at the 95th percentile. An average can hide the one reply in twenty that takes ages.

  4. 4

    Save the token counts

    Store input, cached and output tokens next to each timing, so a slow request can be explained.

Only then change something. Often one stage makes up most of the wait, and that is the one to fix.

How do you make the first words appear sooner?

For a chat screen, streaming is a strong first change, because the reader sees text sooner. Anthropic describes it as "a feature that allows the model to start sending back its response before the full output is complete". The customer reads while the rest is still being written.

Where the wait can be cut

Customer's turn

one question, one turn

Before the model runs

Stable prompt first

same start, so caching can reuse it

Right-sized model

fast model for easy turns

Code answers simple ones

order status from the order system

While the model writes

Stream the reply

text shows as it is made

Shorter output

shorter reply, less waiting

Words start early

the wait the user feels drops

  1. 1The question goes to the stage before the model runs.
  2. 2The prepared request goes to the model, short and cacheable.
  3. 3Text streams out, so the first words reach the screen early.
Three groups, one per stage of a turn: preparing the call, writing the reply, and the words on screen. Each lever either shortens the wait the customer feels or skips a model call where code can answer.

The first word also waits on the input. OpenAI says "A long prompt can delay the first token, especially when much of the input is new." So keep the prompt lean, and send only the context the answer needs.

Prompt caching lets the model reuse the work it already did on the unchanged start of your prompt (the prefix), so the next turn is faster. Anthropic says caching can "Reduce cost and latency for extended conversations", especially with long instructions or uploaded documents. The catch is that caching reuses only an eligible exact prefix match, so one changed word early in the prompt can break it.

  • Stable text first

    Put instructions, tool definitions and fixed policy text at the top. OpenAI advises to "keep the prefix unchanged and append new messages and tool results".

  • Faster model for easy turns

    Use a faster model to sort the question or do a short lookup. "Keep the fastest configuration that meets your quality target, including on difficult cases."

  • Lower effort on easy turns

    Ask for less effort, meaning less thinking per reply, on easy turns. On Claude Haiku 5.5, Anthropic says "Effort is its main control for speed and cost."

Tip

If someone asks how to make it faster, do not start with a model swap. Measure first, then stream, then cut steps. Change the model last.

How do you cut the total wait across all the steps?

A reply can start fast and still take ages to finish, because its steps are chained. The fix is fewer waits in a row and more work at the same time. OpenAI gives the same advice: "Use application code when you already know the answer." If you know an order's status, read it from the order system instead of asking a model.

Same question, two paths

Customer asks

one card question

Before: one step after another

Model call 1

rewrites the question

Model call 2

decides if a lookup runs

Policy, then order

one lookup after the other

Model call 3

writes the whole reply

After: fewer calls, overlap

Route in one call

rewrites and decides at once

Policy and order

fetched at the same time

Reply streams

words show as they are made

Reply on screen

words show early

  1. 1The question goes down the old path, one step at a time.
  2. 2The same question goes down the new path, with fewer calls.
  3. 3The old path shows its reply only after the last call.
  4. 4The new path streams its reply, so words show early.
Both paths answer the same question. The old one waits for each call in turn, then shows the whole reply. The new one routes in one call, fetches two lookups at once and streams the reply, so words show sooner.
  • Combine steps

    One call can rewrite the question and decide if a lookup is needed. OpenAI: "Combine steps when one request has all the information it needs."

  • Run lookups together

    Once you have the order ID, fetch the order and the policy at the same time. OpenAI: "Run independent work concurrently."

  • Skip the model

    Show the order status straight from the order system.

  • Cap the output

    Ask for a shorter answer and set a limit. Anthropic warns that a limit cuts the reply off, "perhaps mid-sentence or mid-word".

Here is the timing sum for one made-up card-support turn. The seconds are assumed. Change them to match your own traces.

Python
# A made-up card-support turn. The seconds are assumed timings, not measurements.
STEPS = {"rewrite": 1.2, "decide": 0.9, "policy": 0.8, "order": 0.7, "reply": 2.4}
FIRST_WORDS = 0.5  # seconds into the reply before text shows

# Before: each step waits for the one before, and the reply shows only at the end.
before_first = sum(STEPS.values())
before_full = before_first

# After: one call rewrites and decides, the two lookups run together, the reply streams.
routed = 1.0
lookups = max(STEPS["policy"], STEPS["order"])
after_first = routed + lookups + FIRST_WORDS
after_full = routed + lookups + STEPS["reply"]

print(f"Before: first words at {before_first:.1f} s, full reply at {before_full:.1f} s")
print(f"After:  first words at {after_first:.1f} s, full reply at {after_full:.1f} s")

Output

Before: first words at 6.0 s, full reply at 6.0 s
After:  first words at 2.3 s, full reply at 4.2 s

How would you cut a support bot's six-second wait?

A customer types "Is the duplicate card fee refunded?" The bot stays silent for six seconds, because five steps run in turn: rewrite the question, decide on a lookup, check the policy, check the order, and write the reply.

  • Today

    First word at 6.0 s

    Five steps in turn, and the reply shows only at the end.

  • Target

    First word at 2.3 s

    One call that sorts the question, two lookups together, and a streamed reply. Full reply at 4.2 s (made-up timings).

  1. 1

    Time every step

    Find out which call takes the time before touching the prompt.

  2. 2

    Merge the first two calls

    One call rewrites the question and decides on a lookup, so the bot waits once instead of twice.

  3. 3

    Fetch the policy and the order together

    The two lookups do not depend on each other, so run them at the same time.

  4. 4

    Stream the reply

    Show words as they come, and buffer only what a safety check needs.

  5. 5

    Replay real chats

    OpenAI advises: "Replay the same support conversations before and after each change."

What do you give up to go faster?

Speed has a price, and a good answer names it. Fast tiers cost more too: OpenAI says its Fast and Ultrafast options, where supported, "charge a premium".

  • “If you check or moderate output before displaying it, buffer enough text to perform that check.”

    OpenAI

  • “It's always better to first engineer a prompt that works well without model or prompt constraints, and then try latency reduction strategies afterward.”

    Anthropic

  • Safety checks cost time

    Output must sit in a buffer before the check, so the first words come later. OpenAI: "Wait for required checks before displaying a result or taking an action such as issuing a refund."

  • Accuracy on hard cases

    Smaller or faster models can miss hard cases, so test those cases on purpose.

  • Cache misses

    A cache miss costs time too. An edited line near the top of the prompt stops reuse from that line on, since only the unchanged start can be reused.

Tip

Name the trade-off you accept. For example, a support bot can show words early but hold a refund until the policy check passes.

What does the interviewer want to hear?

A strong answer covers

  • Measure first: time to first token and end-to-end, at the typical and the slow end.
  • Stream the reply, and buffer only what a safety check needs.
  • Keep the stable prompt first, so caching can reuse it.
  • Cut sequential calls, run lookups in parallel, and skip the model where code knows.
  • Pick the fastest setup that still passes the hard cases, and say what it costs.
  • Replay real conversations after each change.

Common traps

  • Trap"Just use a faster model."

    BetterMeasure first. A model swap can lower quality, and the wait may sit in your tools.

  • Trap"Streaming makes the whole thing faster."

    BetterStreaming shows words sooner. The full answer still takes as long as its steps, so cut the steps too.

  • Trap"Cache everything."

    BetterCaching reuses only an unchanged prefix. Changing an early line breaks the match.

Can you spot the slow part?

Spot the slow part

A bank's support bot waits six seconds before any text shows. The trace: rewrite 1.2 s, decide 0.9 s, policy 0.8 s, order 0.7 s, reply 2.4 s, no streaming. Given this trace, which fix would you try first?

Quick check

Which change shows the first words of a reply soonest, with the same final answer?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q315Why stream tokens?11 min
  2. Q088What is prompt caching, and how does it save money?13 min
  3. Q316TTFT vs tokens/sec vs total latency?12 min
  4. Q334How do you cut cost on a cloud-hosted LLM workload?13 min
  5. Q344What is a p95/p99 latency budget?11 min
  6. Q340How do reasoning tokens affect cost and latency?11 min

Learn it in depth

Last updated on 27 November 2026

Building an AI feature that users wait on?

I design and build AI products and agents, including the screen and the system behind them. Book a short call and tell me where the wait feels too long.