AI latency is often discussed as a model performance metric.

How quickly does the model respond? How long does it take to generate an answer? Can we make it faster?

These are useful questions, but they do not tell us the full story.

In a real enterprise AI application, the model is only one part of the system. Before a response reaches the user, the application may need to authenticate the request, retrieve information, prepare context, call a model, execute tools, validate the result, and return the response.

Each step adds time.

This becomes more important when AI is used in customer service, decision support, document processing, enterprise search, or agentic workflows. A model that performs well in an isolated test may behave very differently when it becomes part of a production application.

The challenge is not simply to make the model faster.

It is to understand where time is spent, measure performance at the right level, and decide what response time is acceptable for the business process.

1. What do we mean by AI latency?

Latency is the time taken for an operation to complete, or for a particular event to occur within that operation.

In AI systems, there is no single latency measurement that answers every question.

We need to distinguish between:

  • Model inference latency: The time associated with processing an input and generating a model response.
  • Time to first token: How long it takes for the first output token to reach the client in a streaming interaction.
  • Token generation speed: How quickly the model generates output tokens after generation begins.
  • End-to-end latency: The time taken for the application to deliver the completed response.
  • Workflow latency: The time taken to complete a larger operation involving retrieval, model calls, tools, orchestration, and validation.

These measurements are related, but they are not interchangeable.

For example, a model might start streaming a response quickly but take considerably longer to complete it. Another model might spend more time reasoning before producing its first token, then generate the answer relatively quickly.

Which one is better depends on the application and what the user needs.

For a conversational assistant, the time before the first response can strongly influence the user experience. For a document analysis process running in the background, total completion time may matter more than the time to first token.

The first step is therefore to define what we are measuring and why.

2. Understanding the latency across an AI system

Consider an enterprise application that answers questions using a large language model and internal documents through retrieval augmented generation, or RAG.

A typical request might follow this path:

User request → Authentication → Retrieval → Context preparation → Model inference → Validation → Response

Each component contributes to the overall response time.

Request processing

The application receives the request, validates the input, checks the user's identity and permissions, and prepares the information required for processing.

The overhead may be small in a simple application, but it still needs to be measured rather than assumed to be negligible.

Retrieval and context preparation

For a RAG application, the system may search a vector database or enterprise search service, retrieve relevant documents, rerank the results, and assemble the context that will be sent to the model.

The time required depends on the retrieval architecture, data source, query complexity, filtering, network calls, and the amount of processing involved.

If retrieval is slow, choosing a faster model may not solve the main performance problem.

Model inference

The model processes the input and generates the response.

This stage is affected by the model itself, the input length, the reasoning performed, the output length, the serving infrastructure, and the conditions under which the model is running.

The model provider's reported latency may cover only part of the complete application journey.

Tool execution and orchestration

An agent may need to call an API, query a database, search a knowledge source, or invoke another agent.

Each additional operation can introduce latency.

Some operations can run in parallel. Others must run sequentially because the output of one step is required before the next can begin.

This distinction matters. A workflow with several sequential model and tool calls can be much slower than a workflow that performs independent operations in parallel.

Validation and response delivery

The application may validate the model's output, check the response against business rules, apply formatting, or wait for the final result before returning it to the user.

The total latency depends on the complete execution path, not just the time spent inside the model.

This is why end-to-end measurement is essential.

3. What affects model inference latency?

Model latency depends on several interacting factors. No single factor explains performance in every environment.

Model size and architecture

Larger models generally require more computation, but model size alone is not a reliable predictor of response time.

Hardware, model architecture, quantisation, inference optimisation, batching, and serving configuration can change the result.

A smaller model may respond faster, but the decision should also consider whether it can deliver the required quality.

Input context length

The model needs to process the input tokens provided in the request. These may include the system instructions, conversation history, user question, retrieved documents, and tool results.

A longer context generally increases the processing required before and during generation.

However, the relationship is not identical across models and serving implementations. Attention mechanisms, caching, and inference optimisations can influence the result.

The practical lesson is to measure latency against representative context sizes rather than testing only with short prompts.

Reasoning and thinking time

Some models perform additional internal reasoning before generating a visible answer. Depending on the model and configuration, this can increase the time before the first output token.

The amount of reasoning may also vary with task complexity and the reasoning settings available.

This creates a trade off. Additional reasoning can improve performance on some complex tasks, but it may also increase latency and cost.

The objective should not be to minimise thinking time in every situation. It should be to use an appropriate level of reasoning for the task.

Output length

Generating a long response generally takes more time than generating a short one.

This is particularly relevant for summarisation, document analysis, code generation, and detailed explanations.

When the application only needs a classification, a short answer, or a structured decision, requesting a long narrative may introduce unnecessary generation time.

Output requirements should therefore be designed around the business need.

Infrastructure and serving capacity

The same model can perform differently depending on where and how it is served.

Relevant factors include accelerator capacity, queueing, concurrent requests, batching, service configuration, network conditions, and provider-side optimisations.

For managed model services, the application team may not control all these factors directly. It can still measure the observed performance and use that evidence to assess service suitability.

4. Time to first token versus total response time

For streaming applications, two measurements are particularly useful.

Time to first token (TTFT) measures the elapsed time from a defined request start point until the first output token is received by the client.

It captures the delay before the user sees the beginning of the response. Depending on where the timer starts, it may include application processing, retrieval, network overhead, queueing, and model processing.

Time to last token (TTLT) measures the elapsed time until the final output token is received.

For a complete response, the difference between these measurements indicates how much additional time elapsed after generation began.

Consider a hypothetical example:

MeasurementModel AModel B
Time to first token1.2 seconds2.0 seconds
Time to last token5.0 seconds4.5 seconds

Model A starts responding sooner, but Model B completes the response sooner.

These numbers are illustrative, not benchmark results.

The example shows why a single latency number can be misleading. If the user values immediate feedback, Model A may feel more responsive. If the user needs the complete answer as quickly as possible, Model B may be preferable.

For streaming systems, also distinguish the time to the last token from the time the full application workflow finishes. A response may still require validation or a follow-up tool action after initial generation.

5. How should we measure latency in practice?

Latency measurement should start with a clearly defined boundary.

For example, the application might record the time when it receives a request and the time when it completes the response. This provides end-to-end application latency.

It should then capture timings for important internal stages, such as retrieval, model calls, tool execution, and validation.

A practical measurement model includes the following.

Request-level measurements

  • Request start and completion timestamps
  • End-to-end latency
  • Time to first token, where streaming is used
  • Time to last token
  • Input and output token counts
  • Success, timeout, and error status

Component-level measurements

  • Retrieval duration
  • Reranking and context preparation duration
  • Model request duration
  • Tool execution duration
  • Validation and post-processing duration

Workload and environment details

  • Model and model version
  • Prompt or configuration version
  • Context size
  • Output length
  • Concurrency and workload type
  • Relevant infrastructure and deployment configuration

The exact metrics depend on the application. The important point is to capture enough information to explain why latency changes.

For example, if end-to-end latency increases while model request duration remains stable, the problem may be in retrieval, orchestration, or another component outside the model.

If model latency increases as context size or concurrency grows, that gives a different direction for investigation.

Measurements should use consistent start and end points. Otherwise, comparing latency across components, models, or environments can produce misleading conclusions.

6. Why averages are not enough

An average latency figure can hide poor experiences for a subset of users.

Suppose most requests complete quickly, but a smaller number take much longer because of queueing, large contexts, slow retrieval, or external service delays.

The average may still look acceptable even when those slower requests matter to the business.

This is why production monitoring commonly uses latency percentiles.

  • p50: The median latency. Half of the measured requests complete at or below this value.
  • p95: The latency at or below which 95% of measured requests complete.
  • p99: The latency at or below which 99% of measured requests complete.

These measurements help reveal the long tail of slow requests.

For a customer-facing application, p95 and p99 can be important because they expose performance problems that averages may hide.

However, percentiles must be calculated over a meaningful sample and an appropriate measurement window. Small samples can produce unstable results, and results should be segmented when different workloads have very different characteristics.

7. Latency in RAG and agentic AI

The architecture becomes more important when the model is part of a larger workflow.

RAG latency

A RAG application may perform query preparation, retrieval, reranking, context assembly, model inference, and output validation.

To understand performance, measure the individual stages and the complete request.

Possible optimisation areas include improving retrieval efficiency, reducing unnecessary context, optimising reranking, and avoiding redundant model calls.

Reducing context length may lower latency, but removing relevant information can damage answer quality. The objective is to provide the right context, not simply the smallest context.

Agentic workflow latency

An agentic system may execute several steps before completing a task.

For example:

Request → Planning → Tool call → Result processing → Additional model call → Validation → Final response

If these steps are sequential, their durations accumulate. If independent operations can safely run in parallel, total elapsed time may be reduced.

The team should measure both individual step durations and the complete workflow.

It should also record how many model calls and tool calls were made for each task. A workflow that takes longer because it executes unnecessary steps may need architectural improvement rather than a faster model.

Retries require particular attention. A retry may improve resilience, but it also increases latency and cost. Repeated retries against a failing dependency can make an already slow workflow worse.

8. Balancing latency, quality, cost, and reliability

Latency should not be optimised in isolation.

A faster model that produces unreliable answers may create more rework or introduce unacceptable business risk. A more capable model may be worth the additional delay for a complex task, but unnecessary for a simple classification.

The decision should consider four dimensions.

DimensionKey question
QualityDoes the response meet the accuracy, relevance, and grounding requirements?
LatencyDoes the system respond within the time the business process can tolerate?
CostWhat is the cost per request or completed task, including retrieval, inference, and tool calls?
ReliabilityDoes the system behave consistently under expected load and handle failures appropriately?

These dimensions need to be evaluated together.

For example, routing simple requests to a smaller model and complex requests to a more capable model may reduce cost and improve responsiveness. But routing introduces its own complexity and must be evaluated for quality and reliability.

Similarly, caching repeated results may improve response time, but it introduces freshness, access control, and invalidation considerations.

Every optimisation involves trade offs. The right choice depends on the use case and its business requirements.

9. Define service objectives before optimising

There is no universal latency target suitable for every AI application.

A real-time conversational assistant, an internal knowledge search tool, a batch document processing service, and an autonomous workflow have different performance requirements.

Start by defining what the user or business process needs.

For example:

  • How long can a user reasonably wait before seeing the first response?
  • How long can the complete task take?
  • What proportion of requests must meet the target?
  • What happens when the target is missed?
  • Can the application return a partial response or use a fallback?
  • Does the task justify additional reasoning time?

These requirements can inform service level indicators (SLIs) and service level objectives (SLOs).

An SLI defines what is measured, such as end-to-end latency. An SLO defines the target for that measurement over a specified period.

The target should be based on the actual use case, observed baseline performance, user expectations, and business impact. It should not be selected simply because another application uses the same number.

10. A practical approach to latency testing

Before putting an AI application into production, I would test it in stages.

First, establish a baseline.

Run a representative set of requests and record latency, token usage, output quality, errors, and cost.

Second, vary the workload.

Test short and long prompts, different context sizes, different output lengths, and different levels of concurrency.

Third, measure the components.

Identify how much time is spent in retrieval, model inference, tool calls, and application processing.

Fourth, test realistic operating conditions.

Include expected peak traffic, timeouts, dependency failures, and relevant retry or fallback behaviour.

Fifth, evaluate the trade offs.

Compare performance changes against response quality, cost, and reliability. Do not accept a latency improvement if it undermines the required business outcome.

Finally, monitor continuously.

Production performance can change as workloads, prompts, data, models, and infrastructure change. Keep the same core measurements available after deployment so that the team can detect regressions and investigate them.

The objective is not simply to produce a benchmark. It is to establish a repeatable way to understand and manage performance throughout the system lifecycle.

Conclusion

AI latency is more than a model metric.

It is a property of the complete request path, influenced by model inference, reasoning, context, infrastructure, retrieval, orchestration, and tool execution.

Measuring only model response time can miss the actual source of delay. Measuring only end-to-end latency can show that the system is slow without explaining why.

A useful approach measures both.

For me, the architectural lesson is straightforward: understand where time is spent, measure performance against a real workload, and make trade offs based on the business outcome.

A fast model is useful.

A fast AI system is better.

But a fast, reliable AI system that delivers the right result is what matters in production.