Skip to content
Agent Month

How to fix: LLM API bill is unexpectedly high

Last verified: June 2026· Production AI features

Where this shows up

Production AI features

How it shows up

The same root cause surfaces in a few different ways. If any of these match, you're in the right place.

  • A monthly invoice that grows faster than usage, with no single deploy anyone can point at as the cause.
  • Spend that appears as one line on a cloud or provider bill, with no breakdown by feature, team or route.
  • A large share of the total traceable to internal or batch work that nobody would have prioritised if they had seen the figure.
  • Costs that jump on days with no traffic increase, usually a background job or an agent workflow that was quietly enabled.

Diagnose it first

Confirm which cause you actually have before changing anything — most wasted time here comes from fixing the wrong one.

CheckWhat the result tells you
Tag every model call with a stable route name chosen in code, then group spend by it.Almost every unexplained bill turns out to be concentrated in a handful of routes. Without this field the question is unanswerable, and with it the answer usually takes an afternoon.
Separate input, output, cached and reasoning tokens in your accounting.Output is priced several times higher than input on most models and reasoning tokens bill as output. A bill dominated by output points at verbose completions; one dominated by input points at prompt bloat or agent accumulation.
Compute cost per unit of work — per conversation, per document, per ticket.An absolute total rises with successful growth and tells you nothing. The per-unit ratio stays flat as traffic grows and moves only when something structural changed.
Look for routes where tokens per call are rising over time.That is the fingerprint of an agent loop re-reading its accumulated context, or of a prompt that has been added to repeatedly and never trimmed.

The fix

  1. 1Instrument every call with tokens, latency, and cost tagged by route and model — you can’t cut what you can’t see.
  2. 2Find the heaviest routes and right-size the model: move low-stakes calls to a cheaper tier behind an eval.
  3. 3Add prompt caching for large stable prefixes and provider prompt caching where available.
  4. 4Move non-urgent work to batch APIs and trim oversized context (retrieve, don’t stuff).
  5. 5Add fallback chains so timeouts don’t trigger expensive retries on your priciest model.

Provider-specific behaviour

The error means roughly the same thing everywhere, but each provider signals it differently.

Cache reads are cheap and easy to lose
Where a long stable prefix is reused, cached input is billed at a fraction of the standard rate. A single dynamic value near the top of a prompt — a timestamp, a session id, a list that reorders — invalidates the prefix on every call and silently multiplies that route's cost.
Batch pricing
Work that does not have to return immediately is usually substantially cheaper through a batch endpoint. Teams routinely run nightly enrichment and backfills through the interactive API purely because that is the code that already existed.

What doesn't work

Common fixes for this error that look right and aren't.

  • Switching everything to the cheapest model.

    Quality drops somewhere you are not measuring, and the resulting rework, retries and escalations often cost more than the saving. Downgrade per route, behind an eval that proves quality held.

  • Shortening prompts by deleting instructions.

    It reduces tokens and can change behaviour in ways that are invisible until a customer sees the output. Compress what is genuinely redundant, and validate the change like any other.

  • Setting a hard spend cap and treating that as the fix.

    A cap converts a cost problem into an availability problem at the worst moment. It is a useful backstop and it is not a cost strategy.

Prevent it

Keep a live cost-by-route dashboard and gate prompt/model changes on evals so savings don’t silently erode.

Common variations and related errors

You'll usually hit this same root cause under a few different names. Same fix.

  • "why is my OpenAI bill so high"
  • "LLM costs doubled"
  • "token usage spiked"
  • "unexplained LLM spend"
  • "AI bill too high"

Frequently asked questions

What causes “LLM API bill is unexpectedly high”?

Spend is invisible by route, so an expensive prompt, oversized context, or a background job is quietly driving most of the cost.

How do I prevent “LLM API bill is unexpectedly high” from recurring?

Keep a live cost-by-route dashboard and gate prompt/model changes on evals so savings don’t silently erode.

Where do I start if I have no visibility at all?

With instrumentation, not savings. Tag every call with a stable route name chosen in code, record input, output, cached and reasoning tokens as separate counters, and compute money at query time from those counts rather than storing a figure that goes stale when prices change. In practice this is a few days of work and it converts a list of plausible savings into a ranked list of real ones.

Which lever usually gives the most?

Right-sizing the model per route, because it is reversible and the effect is immediate — but the caveat matters: only for routes where a smaller model provably holds quality. After that, prompt caching is the one most often broken rather than absent, usually because something dynamic sits near the top of the prompt. Then batching anything not on a user's critical path, then trimming context that has accreted over time.

How do I cut cost without risking quality?

Put an eval suite on the route before you change it, built from real traffic rather than imagined cases, and score the cheaper configuration against the current one. That turns a downgrade from a bet into a measurement, which is also the only version of the argument that survives a conversation with whoever owns the customer experience. The instrumentation that found the money is what proves the saving was free.