PRACTITIONERCHAPTER 09

Cost, latency and choosing the model

Own the budget for one model-backed request: pick the unit that counts, price the quality gap against what it saves, and write down when the prices were read

40 MINAI ENGINEERUPDATED 2026-11-21
PREDICT

Kolanut's care team gets about 30,000 complaint texts a month, and an agent reads each draft before sending. On Wafula's 200-case eval the larger model's draft is accepted 84% of the time and the smaller model's 77%. An accepted draft leaves an agent about 2 minutes of work, a rejected one about 8, and an agent minute costs ₦25. With invented prices, the larger model costs ₦3.83 a draft and the smaller ₦1.28. What does the budget show?

The techniques are taught elsewhere. How a tier differs from another and how to read a leaderboard is in choosing a model. How tokens are counted and priced is in tokens, context and cost. Prompt caching, batching and streaming are in caching, batching and latency. This chapter does not repeat them. It covers what is left once you know them: the job of owning the number, writing it down, defending it to people who count money differently from you, and reopening it on a schedule instead of at every complaint.

The model: a budget for one request

An AI engineer who owns a feature owns a budget for one request. It has six parts.

  1. The unit. What one successful outcome is: a draft an agent accepts, a conversation resolved, a catalogue entry that passes review. Costs are divided by outcomes, not by calls.
  2. The cost per request. Tokens in, tokens out, cached tokens, and any retry, priced at a rate card you have dated.
  3. The cost of a miss. What happens when the output is wrong: agent minutes, an escalation, a refund, a customer who leaves.
  4. The latency target. A percentile and a number, set by what the person waiting needs.
  5. The volume and the ceiling. Requests a month today, what spend triggers a conversation, and what triggers an alert.
  6. A review date. When the prices, the candidates and the eval get read again.

Teams without this budget fail in two opposite ways. Some pick the strongest model because quality is easy to argue for, and find the bill in month three. Others pick the cheapest because cost is easy to measure, and find the quality problem as support tickets. Both made the same mistake: they compared things that were on different scales. A price per million tokens is a cost. A score on an eval is a quality. A budget is what turns them into one decision.

Choose the denominator

The sharpest question in the document is “per what?” Here is Kolanut’s drafting feature priced three ways. The figures are illustrative, built from the numbers in the prediction above.

Measure Smaller model Larger model Reads as
Model cost per draft ₦1.28 ₦3.83 The larger costs 3 times as much
Model cost per accepted draft ₦1.66 (1.275 ÷ 0.77) ₦4.55 (3.825 ÷ 0.84) The larger costs 2.7 times as much
Agent time per ticket ₦84.50 ₦74.00 The larger saves ₦10.50
Model plus agent time per ticket ₦85.78 ₦77.83 The larger saves ₦7.95

The first row is where the argument starts, and it is the least useful. The last row is the one the business pays. Moving from the first row to the last changes the answer, because a model draft is not the product. It is an input to an agent’s work, and the agent’s minutes are the dominant cost. Here the model is about 5% of the cost of a ticket (₦3.83 of ₦77.83), so a 3-times price difference moves the ticket cost by about 3%, while a 7-point quality difference moves it by about 12%.

Zohreh’s agents add a second effect that no price list shows. A rejected draft costs more than no draft: the agent reads it, decides it is wrong, and then writes their own. In the numbers above a rejected draft leaves 8 minutes; if an agent working with no assistant needed, say, 6 (an assumed figure), a rejected draft would cost them 2 extra minutes. A feature with a low acceptance rate can cost more than not having it, and that is a finding the model’s price per token would never reveal.

The break-even gap

You rarely know the quality gap exactly. A 200-case eval gives accuracy rates with an uncertainty: 84% and 77% each carry a margin of a few points, and an unpaired comparison of the two has a standard error of about 4 points. The eval-set chapter explains why, and why a paired run on the same cases, read case by case, is tighter.

So ask a different question. How big must the gap be before the stronger model pays for itself? The larger model costs ₦2.55 more per draft (3.825 − 1.275). Each extra accepted draft saves 6 minutes of agent time (8 − 2), worth ₦150. The break-even gap is 2.55 ÷ 150, about 1.7 points. The measured gap is 7. Even if the true gap were a third of that, the larger model would still pay. That is a much firmer statement than “7 points, give or take 4”, and it is the kind of statement you can put in front of a finance lead.

The same arithmetic tells you when you are wrong. Rearrange it: the larger model pays while an agent minute is worth more than about ₦6 (2.55 ÷ (0.07 × 6 minutes), about ₦6.07). If these drafts went out with no agent in the loop, that agent-time saving disappears, and the comparison has to be against what a customer is worth: the cost of the reply against what Kolanut earns from that customer, a figure finance holds and this chapter does not invent. At that point the recharge size is the right yardstick, and the answer can flip.

Latency is a requirement, not a score

Latency numbers mean nothing until you know who is waiting. In Wafula’s feature nobody is. A complaint arrives by SMS, the draft is made when it arrives, and an agent opens the ticket minutes later. The draft has a generous budget, 30 seconds at the 95th percentile is plenty, and that room is exactly what lets the larger, slower model fit. If the same drafting ran while the agent watched a spinner, the budget would be a few seconds, and the choice of model would change with it.

The usual vocabulary is in the caching and latency chapter: time to first token, tokens per second, percentiles rather than averages. The job-level points are these.

  • Set the target from the user, then measure against it. Write it as a percentile: “95% of drafts ready within 30 seconds of the SMS arriving”. An average hides the tail that people remember.
  • Count the whole path. Retrieval, the queue in front of the model, retries and the network all sit in the number a person experiences. A faster model does nothing for a delay you introduced yourself.
  • Know which lever is cheap. Streaming improves what a person perceives in a live chat and does nothing for a background job. Caching a long stable prefix cuts both cost and the time to the first token. A smaller model cuts both too, at a quality price you have already measured.
  • Plan for the spike. After a network outage Kolanut’s complaints arrive in a burst, and vendors limit requests and tokens a minute. The lesson on LLM rate limits shows how retries make a limit worse, and KV cache and batching shows why one slow request can hold others up. Your budget needs a line for what happens when the ceiling is hit: queue, degrade to the smaller model, or tell the agent no draft is coming.

The order the levers go in

When the budget is over, there is a standard sequence, and the job is to apply it in order and keep the evidence for each step.

  1. Measure first. Log model, tokens in, cached tokens, tokens out, time to first token, total time and outcome for every call. You cannot lower a number you have not split.
  2. Shrink what you send and ask for. A prompt with duplicated rules and an answer longer than anyone reads are the cheapest savings, with no quality risk worth testing.
  3. Cache the stable prefix. Kolanut’s rules and handbook are about 1,500 of each draft’s 1,800 input tokens and identical on every request. Cached reads are billed at a fraction of the normal input price: on the vendor’s pricing page the fraction differs by model, from 0.1 to 0.025 of the base price (checked 2026-11 against the vendor’s published pricing; cache writes cost more than ordinary input, so caching pays only when enough requests arrive within the cache’s lifetimeas of 2026-11). Caching does not change quality, so it needs no new eval, only a check that the hit rate is what you assumed.
  4. Tune effort or output limits within the model, then run the eval again.
  5. Step down a tier, or route. This changes quality, so it needs the whole eval, per slice.

Routing deserves its own warning. Sending easy requests to the small model and hard ones to the large one saves money only if you can tell them apart cheaply and the gap sits in one class. It adds a second model with its own errors and its own eval, and it makes every later change harder to reason about. Research on cascades of models, such as the FrugalGPT paper in the reading list, reports in its abstract that it can match the best single model’s performance with up to 98% lower cost, or beat it by 4% at the same cost. Those are results on its own datasets, not your traffic. In Wafula’s case the most routing could save is the full gap in model cost, ₦2.55 a draft or about ₦76,500 a month (30,000 × 2.55), before the router’s own errors. That does not repay a second system. At a hundred times the volume it would.

Languages add a trap of their own. Text in Yoruba, with its tone marks, and in Pidgin can break into more tokens than the same message in English, so a rate card quoted per token does not translate into a flat cost per message. Measure input and output tokens per language on your own sample before you forecast. The tokens chapter shows why.

Write down when the prices were read

A model-choice document has a short life if it contains prices with no date. Rate cards change, discounts are restructured, tiers are added, and models are retired. The vendor’s own pricing page lists many models side by side, with different cache terms and different rates above a certain prompt length, so “what it costs” is a question with a date on it. This chapter’s naira prices are invented for the exercise and belong to no vendor. Yours must come from the vendor’s page, with the page and the date written next to them.

The same discipline covers availability. A vendor that retires a model gives notice, and the notice period is a fact to record: the Anthropic documentation says it gives at least 60 days’ notice before retiring a publicly released model (as stated on its model deprecations page, checked 2026-11; other vendors, and partner clouds, set their own schedulesas of 2026-11). Sixty days is enough to migrate only if the eval already exists and the budget is a document you can re-run. The migration itself is the subject of model upgrades and regressions. This chapter’s part is the review date: put it on the calendar when you choose, so that a price change or a deprecation notice finds a budget waiting to be updated.

What each partner needs

Finance. They need a monthly forecast with a range, a ceiling that triggers a conversation, and an explanation of what moves the bill. Give them cost per outcome next to total spend, and the volume assumption behind both. Do not defend a model by its quality alone; show them the break-even.

Customer care or whoever lives with the output. Zohreh needs to know whether drafts will be accepted and when the assistant is slow or down. Give her the acceptance rate by language and a plain statement of what happens in an outage. A change of model is a change to her team’s daily work, so tell her before it happens.

Security and procurement. A change of provider or tier can move customer messages to a new processor, which is a matter for the security lead and for contracts. The guardrails chapter covers the technique; the point here is that a cost-driven change goes through the same door as any other.

Where practitioners disagree

Cheapest model that passes, or the best model you can afford? The first is a sound default for high-volume, low-stakes calls. The second suits low-volume work where a failure is expensive, and it is the argument the break-even makes for Kolanut. Both agree that the eval, not the leaderboard, decides.

Route early or late? Some teams build a router from day one; others ship one model and add routing only when the bill shows a class of easy requests. The second group usually spends less effort overall, because most features never reach the volume where routing pays.

Alert on spend or on cost per outcome? A spend alert catches a runaway loop. A cost-per-outcome alert catches a quality drop that makes people retry. Most teams need both, and the second is the one few set up.

Is the small model’s saving real after quality loss? It can be, when the failures are cheap and caught by something else. It is an illusion when the failures reach a person, as with drafts an agent must rewrite. That is why the cost of a miss is a line in the budget.

Day to day

A rhythm for an AI engineer who owns one feature with a care lead and a finance partner. The times are an example; the cadence is the point. It fits inside the loop in an AI engineer’s week.

  • Every day. A quarter of an hour on the dashboard: spend against the day’s share of the ceiling, cache hit rate, the 95th-percentile latency, error and retry counts. You are looking for a step change, not a trend.
  • Weekly. Cost per accepted draft and acceptance rate by language, from the same sample you read for quality. Check that the logged token counts still match the budget’s assumptions. A new rule added to the prompt shows up here first as more input tokens.
  • Every change. Before any prompt, model or setting change ships, compute its effect on the budget as well as on the eval: tokens, cache prefix, cost per outcome. A change near the top of the prompt breaks the cache for every request that follows.
  • Monthly. Re-read the vendor’s rate card and notices, and write the date in the budget. Compare actual spend with the forecast; a miss of more than a fifth, a rule of thumb, means an assumption is wrong. Meet finance for twenty minutes with the forecast and the range.
  • Quarterly. Re-run the eval on the current candidates, including any new tier. A model that failed in spring may pass now, and one you chose may have a replacement. Review the break-even with the care lead, since agent time and volume change.
  • When a notice arrives. A deprecation, a price change or a new tier starts the same short routine: record it, run the eval on the replacement, update the budget, tell finance and care.

When it breaks. If spend runs away, the ceiling is the brake: the first response is to cap or queue, then to find the loop, and only then to discuss models. If latency spikes, check the whole path before blaming the model, and degrade to the smaller one only for the requests where that is safe.

BY ORG SIZE
STARTUPunder 30 people

One engineer picks the model, and the founder reads the invoice. A whole budget is three numbers on a page: the cost of one successful outcome, the quality floor, and the monthly spend at which you stop and look. Run 50 or so real cases through two models before choosing. Set a spend limit and an alert with the vendor so a loop cannot run up a bill overnight. Do not build routing or a gateway. Write the date next to the prices, because you will change models more than once.

SCALE-UP30 to 300

Several features now share a bill and a finance partner who wants it split by product. Tag every request with its feature so cost per outcome can be reported per feature, and log the fields that let you compute it. Budgets multiply, so a short template each feature fills in keeps them comparable. This is also when someone proposes a shared gateway; the platform question is the subject of an AI platform for product teams. Until there is one, the risk is that three teams make three model choices with three different yardsticks.

ENTERPRISE300 and up

Spend is committed in a contract, a gateway or platform team owns the keys and rate limits, and a FinOps function allocates cost to business units. Your budget feeds their allocation, so it must be in their units and on their calendar. A tier change may need model-risk or procurement sign-off, and a new vendor may need a data review. Much of the work is writing the case so that a reviewer who has never seen the feature can check the arithmetic. Keep the eval run and the dated rate card together as the evidence.

ARTEFACT A cost and latency budget per request ~60 MIN
YOU PRODUCEA one-page budget for one model-backed request: unit, cost, cost of a miss, latency target, ceiling and review date

Template

# Budget: <feature>, <owner>, <date>
Unit of success: <what one good outcome is>
Volume: <requests a month> · Review on: <date within a quarter>

## Rate card (name the page and the date it was read)
| Candidate | Input per million | Cached read per million | Output per million |
|---|---|---|---|

## Tokens per request (measured on <n> real requests; by language or class if it varies)
Input: <n> of which stable prefix <n> · Output: <n>

## Quality (eval of <n> cases, paired run)
| Candidate | Success rate | Gap and uncertainty |
|---|---|---|

## Cost per outcome
| Candidate | Model cost per request | Cost of a miss x miss rate | Total per outcome |
|---|---|---|---|
Break-even gap: <extra model cost> / <cost of one miss avoided> = <points>

## Latency
Who is waiting: <who> · Target: <percentile> under <seconds> · Measured: <p50, p95>

## Ceiling and brake
Alert at <naira a month>; at the ceiling the system will <queue | degrade | stop>

## The choice, and what would change it
Chosen: <candidate> because <line from the table>
Reopen if: <volume, price, gap, agent-minute value or a notice crosses a stated line>
WORKED EXAMPLE

Kolanut Mobile is a fictional virtual operator hosted on Lumora Mobile’s network. At its Tier 2 stage it has 120 people and 1.1 million subscribers. Wafula owns a feature that drafts replies to traders’ complaint texts in English, Pidgin and Yoruba for care agents to review. About 30,000 texts arrive a month (illustrative). All prices below are invented for this exercise and belong to no vendor.

Unit. A draft an agent accepts. Tokens. 1,800 in, of which 1,500 are the stable rules and handbook, and 150 out. Rate card (invented), per million tokens. Smaller: ₦500 in, ₦2,500 out, ₦50 cached read. Larger: three times each.

Cost per draft. Smaller ₦1.275, larger ₦3.825; with the 1,500-token prefix cached, ₦0.60 and ₦1.80. Quality (200 cases). Accepted: smaller 77%, larger 84%. Cost of a miss. An accepted draft leaves 2 agent minutes, a rejected one 8, at ₦25 a minute. Agent time per ticket: smaller ₦84.50, larger ₦74.00.

Per ticket. Smaller ₦85.78, larger ₦77.83, a saving of ₦7.95, or ₦238,500 a month. Break-even gap. 2.55 ÷ 150 = 1.7 points against a measured 7 (about 4 either way).

Latency. The draft is made when the text arrives; target: 95% within 30 seconds. Ceiling. Model spend alert at ₦150,000 a month; at the ceiling, queue and tell agents drafts are late. Choice. The larger model with caching (about ₦54,000 a month). Reopen if drafts go out without an agent, if volume passes ten times today’s, or if an agent minute is worth under ₦6.

Now you

You are an AI engineer at Owoleaf. Its in-app support assistant answers customers in their own language from help-centre articles it retrieves. About 60,000 conversations a month (illustrative: the assistant’s share of the roughly 3,000 contacts a day that reach the desk and the assistant together, of which about 30,000 a month reach human queues), each averaging 4 model calls. Each call sends 3,500 input tokens (700 of rules, 2,400 of retrieved articles, 400 of history) and returns 180. Invented rate card per million tokens: smaller, ₦500 in and ₦2,500 out; larger, three times each. On your eval the smaller model resolves 81% of conversations and the larger 85%; a conversation not resolved goes to a person at ₦180. The assistant streams, and the target is a 95th-percentile time to first token under 2.0 seconds; measured, the smaller gives 2.4 and the larger 3.6. Finance has set a model-spend ceiling of ₦550,000 a month. Write the budget and make the choice. Say what you would change next, given that neither model meets the latency target.

Self-check

DECIDE

Wafula must choose the model for Kolanut Mobile's complaint-reply drafts. About 30,000 texts arrive a month, in English, Pidgin and Yoruba, and an agent reads every draft before it is sent. On his 200-case eval the larger model's draft is accepted 84% of the time and the smaller's 77%, at three times the price (invented figures): ₦3.83 against ₦1.28 a draft. An accepted draft leaves an agent 2 minutes of work, a rejected one 8, and an agent minute costs ₦25. The finance lead points to recharges of ₦100 to ₦200 and wants the cheaper model. Which does he recommend?

READING
  1. BOOK
    AI Engineering, Chapter 9: Inference Optimization Chip Huyen, 2025

    Covers where inference cost and latency come from and the techniques that reduce them, including prompt caching. Read it for the levers behind this chapter's order of operations. Read: Chapter 9.

  2. DOC
    Pricing Anthropic

    A real rate card, with cache, batch and long-prompt terms that differ by model. Read it to see why a budget needs the page and the date next to every price.

  3. DOC
    Prompt caching Anthropic

    How cached prefixes work, how long they last and what invalidates them. Use it to check the hit rate your budget assumes is achievable.

  4. DOC
    Reducing latency Anthropic

    Short guidance on choosing a faster model, trimming tokens and streaming, with a note to get a prompt working before optimising it.

  5. DOC
    Model deprecations Anthropic

    Lists each model's status, retirement dates and replacement, and states the notice period. Read it when you set your review date.

  6. PAPER
    FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance Lingjiao Chen, Matei Zaharia and James Zou, 2023

    The research behind routing and cascading between models for cost. Its savings are measured on its own benchmarks, so test the idea on your traffic before counting on them. Read: Abstract and the section on LLM cascades.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Guardrails, injection and abuse cases →