Skip to the page

Cost, speed and serving · core

Latency, streaming and voice

A call has a wait for the first token and then a steady stream of output tokens. Measure each stage, stream to the user, and set a budget per step for voice.

The notes

What you must know

  • Total time is about network plus queueing plus time to first token (TTFT) plus output tokens divided by output speed, plus your own steps: retrieval, reranking, tools and guardrails.
  • Prefill reads all input tokens in parallel and fills the KV cache. It sets TTFT and grows with prompt length and load. Decode makes one token at a time and sets tokens per second.
  • Levers: shorter prompts, fewer chunks, prompt caching, shorter answers, a smaller model, streaming, parallel independent calls and fewer calls in sequence.
  • Measure with per-span timings in traces and look at p50, p95 and p99, plus input and output tokens per request.
  • Streaming: the API sends tokens as server-sent events and the backend forwards them to the browser. The user sees text at TTFT. Show progress before the first token.
  • Streaming makes checks harder: moderation and PII checks run on partial text or at the end, JSON needs a partial parser, and citations resolve at the end.
  • Infrastructure: turn off response buffering for that route, keep timeouts long enough, and cancel the model request when the user leaves.
  • Voice agents need about one second from the end of speech to the first sound. Budget end-of-speech detection, streaming speech-to-text, model TTFT, streaming text-to-speech and network, and stream each stage into the next.

The red pen

Common traps: mistake → fix

  • Mistake: Streaming makes the model faster

    Fix: total time is the same; it makes the wait feel shorter.

  • Mistake: Only the model is slow

    Fix: retrieval, rerank and tools often add seconds.

  • Mistake: Average latency is enough

    Fix: users feel p95 and p99.

Easy to hard

Questions interviewers ask, easy to hard

  1. Where does the time go in a 6-second chat answer?
  2. What are TTFT and tokens per second?
  3. How do you make a document Q&A feel instant?
  4. What goes wrong with streaming and safety checks?
  5. Give a latency budget for a voice agent.

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview