Blog · Chapter 12 · Pricing & cost

Quality per euro, by design

Selecting models on your own data, routing to the cheapest capable model, calculating cost per task and optimising without losing quality.

The chapter in 25 seconds

AI costs scale with usage in a way that classic software costs do not. Chapter 12 shows how to select models, predict cost per task and reduce it without hurting quality. All prices in the book are illustrative; use your provider's current price list.

Select models on your own data

Public leaderboards are a starting point, not an answer. Compare candidates on your golden dataset and weigh reasoning ability, context window, structured-output and tool-calling reliability, multimodality, latency, price, data-processing terms and the availability of fallbacks.

Route to the cheapest capable model

Most requests do not need the largest model. Two patterns:

  • Routing: a classifier or rules send easy requests to a small model and hard ones to a frontier model.
  • Cascading: try the small model first, validate the result (schema, confidence, checks) and escalate only when validation fails.

Cascades with validation are simple to build and often cut cost substantially.

Calculate cost per task

Count tokens per step: input, output and cached input. Multiply by the price, and add embeddings, OCR and infrastructure. For agents, the number of steps varies, so estimate from the distribution in your traces and enforce run budgets so one runaway task cannot burn a month's allowance.

API or self-hosting?

Self-hosting open models pays off only with high, steady volume and the skills to operate GPUs. Below that break-even, APIs are cheaper and better.

Optimise, then re-check quality

Technique Typical effect
Prompt caching Large savings on repeated prefixes
Batch APIs Lower price for non-urgent work
Context reduction Fewer input tokens per call
Routing and cascades Small models for easy cases
Reasoning-effort control Less thinking for easy tasks

After every optimisation, re-run your evaluations. A cheaper system that gives worse answers is not an optimisation.

Key takeaways

  • Select models on your own evaluation data.
  • Route each request to the cheapest capable model.
  • Re-check quality after every cost optimisation.