AI Economics · · Updated

The LLM bill: cost and latency engineering for AI products that scale

The AI feature that delighted ten pilot users can bankrupt itself at ten thousand. Cost and latency aren't tuning knobs to twist at the end — they're architecture decisions, and the best teams make them on day one.

There's a familiar arc to AI features in 2026. A team ships something genuinely useful, adoption climbs, and then a finance review lands: the inference bill is growing faster than revenue, and p95 latency has crept past the point where users start clicking away. The feature works. The economics don't. And because every design decision was made with the biggest model and the longest prompt, the fix looks like a rewrite.

It doesn't have to be. Here's how we think about the economics of an LLM feature from the first sprint.

Know your unit economics before you scale

Every AI feature has a cost per unit of value — per ticket resolved, per document processed, per conversation — and you should be able to state it. Instrument tokens in and out, model calls per task, cache hit rate and latency per step from day one, and tag every call with the feature and customer it served. Without that, "AI spend" is a single scary line on the cloud bill; with it, you know exactly which workflow is expensive and whether it's earning its keep.

A worked example: what routing does to the bill

The arithmetic is simple, and it's worth doing for your own traffic. Suppose a feature sends every request to a frontier model at a relative cost of 1.0 per request. After analysing the traffic, you find 70% of requests are routine and a smaller model that costs a tenth as much handles them just as well. The blended cost is 0.7 × 0.1 + 0.3 × 1.0 = 0.37, or roughly a 63% reduction before any caching. These numbers are illustrative, not a price list, but the structure holds: the savings come from the share of traffic you can safely move down, so measuring that share is the first job.

Route by difficulty, not by default

The most expensive habit in AI engineering is sending every request to the frontier model. Most production traffic is routine: classification, extraction, reformatting, short answers over retrieved text. Small and mid-sized models — including fast-tier and open-weight options — handle these at a fraction of the cost and latency, often with equal accuracy on a bounded task. The pattern that works: a cheap model (or a rule) classifies the request, easy cases go to a small model, hard or high-stakes cases escalate to the frontier model, and your evaluation suite proves the routing didn't cost quality. Fine-tuning a small model on your own traffic often pushes even more work down the ladder.

Prove quality before you downshift

Routing is only a saving if quality holds. Before moving traffic to a cheaper model, run both on your golden set and compare results by request type, not just on average, since a model that's fine overall can fail badly on one segment. Then roll out gradually: shadow the cheaper model on live traffic, compare outputs, and shift a small percentage first. Keep the escalation path, so a low-confidence answer from the small model can retry on the larger one. The goal is a documented decision, not a hunch.

Cache aggressively at every layer

Prompt caching on the providers' side makes long, repeated system prompts and shared context nearly free on subsequent calls — structure prompts so the stable part comes first and the variable part last. Above that, semantic caching returns stored answers for questions that are near-duplicates of ones you've already answered; in support and internal-knowledge use cases, hit rates of 20–40% are common. And below it, cache the expensive non-model steps too: retrieval results, embeddings, parsed documents.

Prompt hygiene is cost hygiene

Prompts accrete. Every incident adds a paragraph of instructions; every edge case adds an example; six months later the system prompt is 4,000 tokens and nobody knows which parts still matter. Audit prompts the way you'd audit dependencies: measure what each section contributes with your eval suite, cut what doesn't, and move stable reference material into retrieval so it's fetched only when relevant. Constrain output too — structured output schemas and explicit length limits stop the model from padding your bill with prose nobody reads.

Context is the hidden multiplier

Costs often grow without anyone changing a prompt, because context grows. Conversation history accumulates turn by turn, retrieval returns more passages than the answer needs, and tool outputs paste whole API responses into the window. Each call then re-pays for all of it. Set a context budget per request and enforce it: summarise old turns, tune the number of retrieved passages against your evaluation set, truncate verbose tool results to the fields that matter, and trim anything the model hasn't used in several turns. Where a provider offers adjustable reasoning or "thinking" effort, match it to the task, since a lookup doesn't need the same deliberation as a multi-step analysis.

Design for latency the user feels

Users don't experience average latency; they experience the slow tail and the blank screen. Stream tokens so something appears in under a second. Run independent steps in parallel instead of in a chain. Kick off retrieval speculatively while the user is still typing. Set per-step timeouts with graceful fallbacks so one slow provider call doesn't stall the whole task. And for multi-step agents, cap the step count — an agent that "thinks" for forty calls is a cost incident and a latency incident at once.

Set budgets and alerts like any other SLO

Cost and latency deserve the same operational discipline as uptime. Define targets per feature: a maximum cost per task, a p95 latency goal, a ceiling on steps per run. Alert when a feature drifts past them, and set per-tenant or per-user quotas so one runaway integration, or one looping agent, can't consume the month's budget overnight. Review spend by feature weekly at first; the pattern of what's growing usually points straight at the next optimisation.

Batch what nobody's waiting for

A surprising share of AI workload isn't interactive: nightly document classification, enrichment, summarisation of yesterday's tickets, evaluation runs. Providers price asynchronous batch processing at a steep discount, and you can point it at smaller models with generous timeouts. Separating the interactive path from the batch path is often the single biggest line-item win.

API, managed platform or self-hosted?

Teams often ask whether running open-weight models themselves would be cheaper. Sometimes, but the comparison needs honest accounting. Self-hosting means paying for GPUs whether or not they're busy, plus the engineering time for serving, scaling, upgrades and monitoring. It tends to make sense with high, steady volume, strict data-residency requirements or a narrow task where a small tuned model does the job. Hosted APIs usually win while volume is uncertain or spiky, because you pay only for what you use and get new model generations without a migration. Compare total cost of ownership at your real utilisation, not list price per token.

Frequently asked questions

How do I reduce LLM API costs without hurting quality?

Start by measuring cost per task, then work down the list: route easy requests to smaller models, enable prompt caching with stable content first, trim prompts and retrieved context, constrain output length and format, and batch non-interactive work. Verify each change against an evaluation set so you know quality held.

What is prompt caching?

Prompt caching lets a provider reuse the processed form of a repeated prompt prefix, such as a long system prompt or shared documents, so later requests that start with the same content are cheaper and faster. To benefit, put stable content at the start of the prompt and variable content at the end.

How do I reduce LLM latency?

Stream responses so users see output quickly, run independent steps in parallel, shorten prompts and outputs, use smaller models for simple steps, cache repeated work and cap the number of steps in agent loops. Measure p95 and p99, since the slow tail is what users remember.

Is fine-tuning a smaller model worth it?

Often, for high-volume, well-defined tasks such as classification, extraction or formatting. A tuned small model can match a larger one on that narrow job at lower cost and latency. It adds training and maintenance effort, so it pays off when volume is high and the task is stable.

The short version

Profitable AI features are engineered, not lucky: measure cost per unit of value from day one, route by difficulty, cache at every layer, keep prompts lean and outputs constrained, design for tail latency, and batch the work nobody is waiting for. Do that and scale becomes the goal again instead of the threat.

If your AI feature is winning users and losing money, let's look at the bill together.

Related reading

Is your AI feature paying for itself?

We build AI products with cost and latency engineered in — model routing, caching and observability from the first sprint.