The hidden costs in production LLM apps
Hidden LLM costs in production apps: retries, growing prompts, reasoning tokens and upkeep that inflate your AI bill, and how to find each one of them.
Updated
The hidden costs in a production LLM app are the ones that never appear on the price sheet. They come from prompts that grow, output nobody planned for, retries, and the engineering time needed to keep a feature working after a model changes. Most teams budget from the per-token rate and the user count, then get surprised by the bill because they missed how many calls each task really makes.
Where the bill really comes from
The bill is not the rate times the number of users. It is the number of calls per task, times the tokens sent and received on each call, times the rate. Miss one factor and the budget is wrong. A feature that looks cheap per request can cost several times more per finished task once retries and a second pass are counted.
Here is a worked example with illustrative numbers, not measurements. Suppose a task makes one call that succeeds, and every fifth task needs one retry. The average is 1.2 billed calls per task, not 1, and that 20 percent gap is spend nobody budgeted. Add a verification pass on every task and the figure becomes 2.2. Use the cost calculator to plug in your own rate and call count.
Prompts and output that grow quietly
Prompts almost never shrink. Someone adds a rule after a bad answer, someone pastes a longer example, someone adds three fields to the JSON. Each change is small, but the system prompt is sent with every call, so the growth multiplies by the call count. Nobody notices unless input tokens are logged per call.
Output usually costs more per token than input, so answer length matters as much as the question. Some models also reason before they answer, and those thinking tokens are billed as output even when the visible reply is one word. The reasoning token guide shows how to see that line in your logs.
Common mistake: asking for a full explanation when the product only reads one field. Set an output limit on every call, and request only the fields the screen or the database actually uses.
Retries, fallbacks and rate limits
A request that the provider processes and then retries is billed twice. A reply that fails to parse and gets sent again is billed twice. A fallback to a second provider when the first is slow adds a second bill, often at a different rate. None of this shows on the feature’s dashboard. It shows up as spend that grows faster than traffic.
Track the retry rate per feature as its own number. If it is high, the cost problem is really a reliability problem, and fixing the failure removes spend that a lower price never touches. Rate limits add their own cost through queuing, backoff and higher plan tiers. Living with rate limits covers the options.
Common mistake: a client-side timeout that gives up on a request the provider still finishes. Check whether abandoned requests are billed, because a retry after a timeout can pay for the same work twice.
Calls you did not need to make
Some calls run inside loops that process the same document again. Some run on every page load when the answer has not changed. Some run before a cheap rule would have ruled the case out. Each one is a line item that nobody reviews.
Prompt caching lowers the cost of a repeated prefix, but only when the prefix is identical on every request and the cache is actually hit. Put the stable instructions first and the changing document last. The prompt caching guide explains when it helps and when it does nothing. For work that no user is waiting on, batch processing is usually the simplest discount to take.
Engineering time after a model change
Providers retire models on a schedule you do not control. When a model is shut off, someone has to test the replacement, rewrite prompts and check outputs again. Prompts tuned for one model often drift on the next. That work recurs and is paid in salary, not tokens, so it never reaches the API invoice.
A test set you wrote, run against every candidate model, makes each change cheaper. Without one, every prompt edit is a guess about whether the output got worse. Running a model you control means you choose when it changes.
Trade-off: a stronger model may cost more per call but need fewer prompt rewrites and fewer retries. Compare the total cost per finished task, not the rate on the price sheet.
How to find your own hidden costs
Start with cost per task, not cost per token. For each feature, log the model, input tokens, output tokens, retry count and calls per user action. Sum the cost, then divide by the tasks that finished. That number is what the feature really costs to run.
Compare cost per task with what the task is worth to the business. A per-token rate alone will not show you that gap. An AI cost audit shows what the code is doing before you start measuring.
Checklist for the first pass:
- Tag every AI call with its feature, model, input and output tokens, and retry count.
- Compute cost per finished task for each feature.
- Compare that figure with the value of the task.
- Track the retry rate and fix the most common failure first.
- Set an output limit and a timeout on every call.
- Find loops and repeated calls, and cache or batch the ones that allow it.
If you want the hidden costs in your own code listed, book a free audit with Own Weights. We read the code and show every AI call, the model it uses, an estimated cost, and checks for missing caching, missing output limits, calls with no timeout, and calls inside loops.
Questions
What are the hidden costs of using an LLM API?
Costs beyond the list price come from the number of calls, the size of each prompt, and the output tokens the model produces, including reasoning tokens. Retries, fallbacks and rate-limit handling add calls that rarely appear on a feature's dashboard. The engineering time to keep prompts working after a model change is a real cost too, even though it never shows on an API invoice.
How do I find out what my LLM app really costs per task?
Log the model, input tokens, output tokens, retry count and calls per user action for every request, tagged by feature. Add up the cost for each feature and divide by the number of tasks that finished. That figure is what the feature costs to run, and it is the number to compare against what the task is worth.
Do retries count toward LLM API costs?
Yes, if the failed request was processed before it was retried. A timeout that still runs on the provider's side, or a bad JSON reply that gets sent again, can both be billed twice. Track the retry rate per feature so you can see where failures are adding spend.