Concepts / Evaluating Model APIs

Evaluating Model APIs

Inference efficiency matters because a model's usability depends heavily on its inference cost and latency.

  • Programming

Two Assistants, One Model

Imagine two AI assistants built on the same underlying model. The first returns its answer after a noticeable pause, and each word arrives slowly. The second starts answering almost immediately and keeps going at a steady pace. The content of both answers may be identical, yet a user will probably find the second assistant more pleasant to work with. The difference lies in how efficiently the model's inference runs, and that difference shapes which applications can reasonably be built on top of the model.

What do you think happens?

Both assistants use the same model and give the same content. Which one would a user probably judge as more pleasant to work with, and why?

  • The one that pauses before answering and then types slowly

  • The one that starts answering almost immediately and keeps a steady pace

Reveal answer
Answer:

The assistant that starts answering almost immediately and keeps a steady pace.

The source says a user will probably judge that second assistant as more pleasant, even though the content is identical. What differs is how efficiently inference runs, which affects the experience of using the model.

The question this article answers is how to measure that difference. Before you can judge whether one model API is efficient, or whether an optimization helped, you need to know what you are measuring. The sections below follow a single response through inference, separate the main efficiency metrics, and then look at the trade-offs and the layers where optimization happens.

Why Cost and Latency Decide Usefulness

A model's usability depends heavily on its inference cost and latency. Inference cost is what it takes to run the model for a request. Latency is how long the user waits. These two properties decide what can be built with a model. Cheaper inference makes AI-powered decisions more affordable, and faster inference makes it possible to place AI in a wider range of applications.

Cost and latency are not separate concerns that happen to sit side by side. A model that is accurate but too slow for a conversation, or too expensive to run on every request, may still be impractical to deploy. Usefulness is therefore a property of the model together with the way it is run, not of the model's answers alone.

Three Questions About One System

The source groups the common efficiency metrics into three families: latency, throughput, and utilization. Each one answers a different question about the same running system. Latency asks how long a single request takes to get a response. Throughput asks how much work the model can process over a period of time. Utilization asks how much of the available hardware capacity is being put to use. Keeping these questions separate matters because a system can look excellent on one of them and poor on another.

MetricWhat it tracksQuestion it answers
LatencyTime for a single request to get a responseHow long does one request take?
ThroughputAmount of work processed over a period of timeHow much work can the model get through in a given time?
UtilizationShare of available hardware capacity in useHow much of the available hardware is being used?

The three common efficiency metric families, as the source describes them

The three metrics are not interchangeable. A request can have a short wait while the system as a whole handles only a modest amount of work, or it can handle a large amount of work while each request waits longer. Reading one metric alone gives an incomplete picture of the system.

Splitting Latency into Two Clocks

For language model-based inference, the source recommends looking inside latency rather than treating it as one number. Latency can be split into two parts. One clock measures how long you wait before anything appears. The other measures how quickly the rest of the output follows. The diagram below traces one response to show where each clock starts and stops.

Request sentPrefillingtakes in the inputFirst tokenfirst word appearsDecodingproduces later tokensFinal tokenoutput completeinputTTFTnext tokenTPOT per token
Which part of inference produces the wait before the first word appears, and which produces the steady delay between later tokens?

Think about a single response being generated one token at a time. Before the first token appears, the model has to take in the input, which the source ties to the prefilling phase. Only after that does the model produce the rest of the output, which the source ties to the decoding phase. The two latency clocks are therefore not interchangeable. One is paid at the start of a response, and the other is paid again for every token that follows.

Tracing the Two Assistants

Worked example

Locating the slow part of each assistant

The first assistant pauses before answering and then types slowly. The second assistant starts almost immediately and keeps a steady pace. Which clock explains each difference?

  1. 1
    Identify the pause before anything appears

    The first assistant's long pause is a wait before the first word, which is the clock measured by TTFT.

  2. 2
    Link that wait to the right phase

    TTFT is influenced by prefilling, so the first assistant's start-up delay points to how it takes in the input before producing output.

  3. 3
    Identify the slow pace after the first word

    The first assistant also types slowly after it begins. That is the clock measured by TPOT, which the source links to decoding.

  4. 4
    Compare with the second assistant

    The second assistant has a short TTFT and a steady TPOT. Both clocks are better, even though the model and the content are the same.

Result

The first assistant is slower on TTFT and possibly on TPOT, so its inference efficiency is weaker. The model itself is the same in both cases, which shows that serving efficiency shapes the user's experience.

The Latency-Throughput Trade-Off

Throughput is the lens through which cost is most directly seen. The source states that throughput metrics are directly related to cost. The more inputs a system can process in a given period, the more work each unit of hardware and time is doing. When throughput is low, the same hardware must stay busy for longer to handle the same workload, and that expense accumulates.

The more important lesson is the trade-off the source names between latency and throughput. Reducing latency often increases cost, and you can potentially reduce cost if you are willing to accept higher latency. The two metrics pull against each other. The diagram below sets the two tunings side by side.

Fast singleresponsesLarge volume ofrequestsLower latencyHigher throughputLess work per periodmay raise costLonger wait perrequesteach request may wait moretuned fortrade-offtuned fortrade-off
When more requests are batched together, how does throughput change, how does each request's latency change, and why does that affect cost per token?

Neither end of this trade-off is automatically correct. A system tuned to answer each request as quickly as possible often gives up some ability to handle many requests at once. A system tuned to handle a large volume of work may make each individual request wait longer. The right balance depends on what the application needs.

Hardware Is Part of the Measurement

All of these metrics depend on the physical machine doing the work. The source is direct about this: how efficiently a model can run depends on the hardware it runs on. The same model can therefore show different latency and throughput numbers on different hardware. The source also notes that optimizing models on different accelerators is important. It gives only this high-level point, so the key idea for this article is that hardware is part of the efficiency picture and cannot be ignored when comparing numbers.

Model-Level Versus Service-Level Optimization

Once you can measure efficiency, the next question is how to improve it. The source describes inference optimization techniques operating at two levels: the model level and the inference service level. The distinction is less about speed and more about what is allowed to change. Model-level optimization often requires changing the model itself, and the source warns that this can lead to changes in model behaviors. Inference service-level optimization typically keeps the model intact and changes only how the model is served.

InferenceoptimizationModel levelchanges the model itself,may alter behaviorInference servicelevelkeeps the model intact,changes how it is servedlayerlayer
What is contained within the model itself versus the serving system around it, and which optimizations act on each layer?

The layers answer different questions. A model-level change asks what the model should be. A service-level change asks how a fixed model should be run for the people using it. When a provider describes an optimization, knowing which layer it sits on tells you whether the model's behavior may have changed.

Common Misreadings of Efficiency Numbers

  • Common mistake

    Treating latency as a single number

    What it looks like

    Reporting one speed figure for a response and concluding that the system feels fast or slow.

    Why it fails

    The source recommends separating latency into TTFT, influenced by prefilling, and TPOT, influenced by decoding. Two systems can share a total time and still feel different to a user.

    Do this instead

    Ask separately how long the first token takes and how steady the later tokens are.

  • Common mistake

    Assuming high throughput always means a better experience

    What it looks like

    Choosing a setup because it handles the most requests, even though each request waits longer.

    Why it fails

    The source names a trade-off in which lower latency often increases cost, and a system optimized for volume may make individual requests wait longer.

    Do this instead

    Decide which side of the trade-off the application needs before choosing the tuning.

  • Common mistake

    Comparing numbers measured on different hardware

    Why it fails

    The source states that efficiency depends on the hardware the model runs on, so the same model can show different results on different machines.

    Do this instead

    Compare latency and throughput only when the hardware and conditions are comparable.

  • Common mistake

    Confusing the optimization layer with the speed result

    What it looks like

    Assuming that a faster service must have a different model.

    Why it fails

    Service-level optimization typically keeps the model intact and changes only how it is served.

    Do this instead

    Identify whether an optimization sits at the model level or the service level before judging its effect on behavior.

Questions to Ask a Model API Provider

The source makes a practical point: most application developers will use model APIs with the optimizations already built in, rather than implementing these techniques themselves. You do not need to build an optimization stack to evaluate one. Understanding what is possible gives you better questions to ask when a provider quotes a fast or cheap service.

Best practice

When a provider quotes speed or cost, ask which latency component the figure describes, whether it is measured against throughput or per request, what hardware it was measured on, and which optimization layer is responsible for the gain.

Classify the Efficiency Claim

MEDIUM

A provider says its model answers quickly and handles many requests at once. For each claim, decide which metric family it refers to, which latency clock or trade-off it touches, and which optimization layer might be responsible. Write one sentence for each.

Hints
  • Quick answers relate to latency, and the time before the first word is TTFT.
  • Handling many requests at once relates to throughput, which the source ties to cost.
  • If the model's behavior may change, the optimization is at the model level.

Recap of Efficiency Concepts

  1. 1
    Cost and latency largely determine whether a model is practical to use, because they decide what applications can be built on it.
  2. 2
    The three common efficiency metric families are latency (time for one request), throughput (work over time), and utilization (share of hardware capacity in use).
  3. 3
    Language model latency splits into TTFT, influenced by prefilling, and TPOT, influenced by decoding.
  4. 4
    Latency and throughput trade against each other, and throughput is directly related to cost.
  5. 5
    Model-level optimization can change model behavior, while inference service-level optimization usually keeps the model intact and changes how it is served.

Key Takeaways

  • Cost and latency largely determine whether a model is practical to deploy, because they decide which applications can be built on it.
  • Latency, throughput, and utilization each track a different aspect of a running system, so they should be read separately.
  • Language model latency splits into TTFT, influenced by prefilling, and TPOT, influenced by decoding.
  • Throughput is directly related to cost, and lowering latency often increases cost, so the right balance depends on the application.
  • Model-level optimization can change model behavior, while inference service-level optimization typically keeps the model intact and changes how it is served.

Related concepts

More concepts starting with E