AI & Data

Managing the cost of AI systems in production

Inference costs scale with usage in ways that surprise teams. A few architectural decisions control most of the bill.

Key takeaways

  • Track cost per request and per resolved task from day one.
  • Route by difficulty rather than sending everything to the largest model.
  • Oversized context is the most common cause of runaway cost.
  • Rate limits and spending caps belong in the initial build.

Know your unit cost

Track cost per request, per user and per resolved task from the first day. An aggregate monthly figure tells you the bill; the unit cost tells you whether the system is economic.

Log token counts alongside outcomes so the relationship between cost and value is visible rather than inferred.

Route by difficulty

Not every request needs the largest model. A smaller model handles routine cases well, with escalation to a larger one when confidence is low or the task is complex.

  • Classify difficulty cheaply, then route.
  • Cache responses for repeated identical queries.
  • Use retrieval to keep context small rather than sending entire documents.
  • Batch asynchronous work where the platform offers reduced rates.

Context length is the usual culprit

Sending large amounts of context on every request is the most common cause of unexpected cost. Better retrieval that sends five relevant passages instead of fifty reduces cost and usually improves quality.

Trim conversation history deliberately rather than accumulating it indefinitely.

Set limits before you need them

Rate limits per user, spending alerts and a hard cap prevent a loop or an unusual usage pattern turning into a large invoice.

Build these in at the start. They are simple then, and they are written under pressure after an incident otherwise.

Forecasting cost before committing

Cost surprises usually come from usage patterns nobody modelled. Before committing to a design, estimate tokens per request for each request type and multiply by realistic volume, including the retries and failures that will happen.

Model a pessimistic case as well: what if usage is five times the estimate, or if users write much longer inputs than expected? Knowing the ceiling informs whether limits are needed and where.

Revisit the model against actuals after a month in production. The gap between estimate and reality is usually instructive and worth feeding into the next design.


Frequently asked questions

It can be at sustained high volume, and it moves cost from per-token pricing to infrastructure and operations. Below substantial usage, hosted endpoints are usually cheaper in total.

For identical or near-identical queries, yes, and it is very effective for support-style workloads where the same questions recur.

Measure token usage per request type in a pilot, multiply by expected volume, and add margin. Retrieval systems are more predictable than open-ended conversation.

Working on this?

A conversation with our team, no charge and no obligation.

Book a conversation