Latency
Definition
The time from sending a request to a model to getting the response, often split into time to first token and total generation time.
In more detail
Streaming makes responses feel faster by showing tokens as they arrive. Long prompts, reasoning and tool calls all add latency; caching and smaller models reduce it.
Measure latency in parts: time to first token, generation speed, and time spent in retrieval and tool calls, which in agents often dominates. Record percentiles such as p50 and p95 per feature in your traces. The usual fixes, in rough order of effort, are shorter prompts, prompt caching, streaming, parallel tool calls, a smaller or faster model for simple steps, and lower reasoning effort.
Related terms
Inference
Running a trained model to produce outputs, as opposed to training it. Inference cost and speed decide what an AI feature costs to run.
Prompt caching
Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.
Rate limit
A provider's cap on requests or tokens per minute or per day; requests over the cap are rejected with an error until the window resets.
Reasoning effort
An API setting that controls how much a reasoning model thinks before answering, trading cost and latency against accuracy.
Speculative decoding
A speed-up where a small draft model proposes tokens and the large model checks them in one pass, keeping the ones it accepts.
Speech-to-text (STT)
A model that converts spoken audio into written words, used for transcripts, captions, voice commands and meeting notes.
Read more about Latency
- Stream LLM responses to a web page with server-sent events
A Node server relays tokens as server-sent events, the page renders them as they arrive, and a Stop button cancels.
- LLM observability
Tracing requests, tokens, latency and cost in AI applications running in production.
- Time to first token
How long a model takes to return the first token of a response after a request, the main driver of how fast a streamed reply feels.
- LLM cost optimisation
Cutting LLM costs with caching, model routing, batching and budgets.