"Keeping the LLM bill predictable: token ceilings, attempt caps and cost budgets"
Every LLM cost horror story I've looked at had the same root cause, not an expensive model, but a missing guardrail. Here are the six controls that make an AI feature's bill boring: token ceilings, attempt caps, per-feature budgets, model tiering and batching, caching, and cost per outcome.

If you have an AI feature in production, there's a decent chance you've had the moment: you open the provider's billing page, and the number is not the number you expected. Maybe it's three times last month. Maybe it's three times last week. And the worst part is you can't immediately say why, which means you can't say it won't happen again.
Here is the pattern I've seen every time I've dug into one of these: the horror story is almost never caused by an expensive model. It's caused by a missing guardrail. A loop that retried forever, a prompt that quietly grew to include an entire document history, a feature that got popular without anyone noticing what each use cost. Expensive models make a bill higher; missing guardrails make it unbounded. Those are very different problems, and only one of them should scare you.
The first guardrail is a ceiling on every single call. On the input side, that means truncating or summarising what goes into the prompt, if a user can paste a 400-page document into a field that flows into your prompt, your cost per request is whatever your users decide it is. On the output side, set the maximum output tokens deliberately, it's an enforced per-response cap, and it should come from what the feature actually needs, not from the model's limit. Once every call has a ceiling, a single request has a known worst-case price, and everything else builds on that.

The second is an attempt cap on anything that loops. Retry logic, agent loops, the re-ask pattern where you feed a validation error back to the model, all of these are loops, and an unbounded re-ask loop is an unbounded invoice. Some inputs will never succeed no matter how many times the model tries, and without a cap the system will happily spend money proving that all night. Two or three attempts, then fail closed and flag it. Bounded attempts times bounded call cost equals a worst case you can write down: a weird input costs you a known amount, not an open question.
Third: budgets and alerts per feature, not just per account. An account-level spend alert tells you something is wrong; it doesn't tell you what. When the extraction pipeline, the support summariser and the search feature all draw from one pot, a runaway in any of them hides inside the total for weeks. Tag every call with the feature it belongs to, Langfuse or a similar tracing layer makes this straightforward, but even a column in your own logs works, and alert when any single feature deviates from its own baseline. That turns "the bill is high" into "the summariser doubled on Tuesday", which is a fixable statement.
Fourth, stop sending everything to your best model. The per-token price gap between a provider's smallest model and its flagship is typically five to ten times, sometimes more. In most workloads the majority of requests are short, clear and routine, and the cheap model handles them indistinguishably well. Route the easy eighty per cent to the cheap tier and reserve the expensive model as the escalation path when the cheap answer fails validation or comes back with low confidence. And where the work isn't latency-sensitive, overnight document runs, weekly summaries, the major providers' batch endpoints charge a flat half price, a discount you collect just for being willing to wait. In the systems I've worked on, tiering has taken more off the bill than any other single change, and your evaluation set will tell you honestly where the cheap model is good enough.
Fifth, cache. Production traffic is more repetitive than you'd expect: identical questions, the same document processed twice, near-duplicate requests minutes apart. Exact-match caching on a hash of the input is an afternoon's work and free money thereafter. Provider-side prompt caching handles the other kind of repetition, the large shared prefix of system prompt and reference material resent on every call, by billing cached input at a fraction of the normal rate, roughly a tenth on Anthropic's API. Semantic caching for near-identical requests is more work and worth it only at volume. Start with exact-match.
The measurement that ties all of this together is cost per business outcome. Not cost per thousand tokens, cost per processed document, per resolved ticket, per qualified lead. Tokens are the provider's unit; outcomes are yours. When you know a processed document costs you a few pence and saves twenty minutes of someone's time, the bill stops being frightening and becomes a line item you can defend, or a signal that the feature isn't worth what it costs, which is equally valuable to know early. In my experience this is also what makes AI genuinely workable for smaller organisations: not cheaper models, but costs that are known.
One honest caveat, because it's the part that gets glossed over: guardrails will occasionally reject work that a bigger budget would have handled. A document that needed a fourth attempt, a query that deserved the expensive model but got routed cheap. That's not a flaw in the approach, that trade is the point. You are choosing a bounded, predictable cost over a marginally higher success rate. Make that choice deliberately and revisit the numbers as the feature proves its value, don't remove the limits the first time one fires.
This is exactly the kind of work I do, building and hardening LLM systems so they're reliable and their costs are boring. If your AI feature's bill is a source of anxiety rather than a line item, get in touch via the contact form.
Senior engineering roles — or production AI consulting?
I'm open to senior AI and software engineering roles and to selective consulting on agents, RAG, and LLM automation in production. If this post resonates — as a hiring manager or as someone shipping similar work — get in touch.
Get in touch