Chapter 6 · Part 3
Measure, then put it to work
Every lever in this course has a failure mode: applied blindly, it saves tokens and quietly wrecks quality. The teams that cut bills 10× without breaking their product all work the same way — they treat cost per request as a metric, sitting right next to latency and error rate on the dashboard.
The loop:
- Measure first. Every API response reports exactly how many input and output tokens you used — log it. Break it down by feature, by model, by user segment. You cannot optimize a bill you can't see.
- Find the whales. Cost is never uniform: it's one chatty endpoint, one bloated prompt, one agent loop resending a giant transcript. The top three offenders are usually 80% of the bill.
- Change one lever at a time, against a quality test set — exactly the iteration discipline from the prompting course. Swap the model or trim the prompt or enable caching; measure both cost and quality; keep what holds.
Do that a few times and the bill stops being scary. Scroll through where this craft earns its keep.
Consumer chatbots: pennies per conversation, multiplied by millions — caching is survival.
You now know where the money goes
The whole course in six lines:
- You pay by the token — two meters, and output runs ~5× input.
- The context tax — stateless models re-buy the whole history every turn.
- Right-size the model — 5–10× gaps between tiers; route by difficulty.
- Cache what repeats — byte-identical prefixes at ~10% of the price.
- Trim, cap, batch — shorter prompts, constrained outputs, half-price nights.
- Measure. Cost per request is a dashboard metric, not a monthly surprise.
None of it requires new math — just knowing that the meter exists and which way it spins. If you want the deeper story of why serving models costs what it does, the inference course is the natural next read — and the other courses go deeper still.