Where LLM bills actually go

An LLM bill is a meter reading, not a subscription: every API call is charged for the tokens it consumed, split by direction — the tokens you sent in and the tokens the model sent back — at the rate of whichever model handled that call. Nothing in that sentence is complicated, yet almost every surprise bill comes from one of its clauses being forgotten: the input side quietly includes your entire conversation history, output tokens are priced at a multiple of input tokens, and a call that failed halfway still metered what it generated. This article takes the bill apart line by line — the price gap, the compounding history, the cache, the calls nobody remembers making — and ends with the only reliable way to cut it: attribute every token to a feature and a user before you optimise anything. If you have a usage export from your provider, open it in the LLM Usage Analyzer and read along with your own numbers in front of you.

Two prices, not one: input and output are metered separately

Every call has two halves, and they are not priced alike. The input is everything you send: the system prompt, the conversation so far, retrieved documents, tool definitions. The output is everything the model generates back. Providers price output at a multiple of the input rate — the exact ratio varies by model and provider, and the LLM pricing table tracks the current numbers — because the two directions are different kinds of work: reading a prompt can be processed in parallel, while generating is one token at a time, each step waiting on the last. The practical consequence is that a feature’s cost profile depends on its shape. A classifier that reads a long document and answers with one word is input-heavy and cheap per call. A writing assistant that takes a one-line brief and returns an essay is output-heavy, and its bill is set by how much it writes, not by what you asked.

Two corollaries surprise people. First, with reasoning models, the model’s internal thinking tokens are billed as output even though you never see them — a short visible answer can hide a long, metered train of thought behind it, and a model that “thinks longer” on hard prompts costs more for reasons invisible in the response body. Second, caps matter more than hopes: a maximum output length is a hard cost ceiling per call, while asking the model to “be concise” is a suggestion it may or may not take. If a line item on your bill feels unexplained, split it by direction before anything else. Most mysteries resolve into either an input side that grew or an output side nobody capped.

The compounding line: your history is re-billed on every turn

Chat APIs are stateless. There is no session on the server quietly remembering your conversation; every request resends the system prompt, the full history and the new message, and the provider meters all of it, every time. Turn ten pays for turns one to nine again. The arithmetic compounds: if each turn adds roughly the same amount of text, the input billed across a session grows with the square of the number of turns — a twenty-turn conversation does not cost twenty times a single exchange, it costs far more, and the growth is entirely in input tokens nobody consciously wrote. This is why two products with identical call counts can have wildly different bills: one answers one-shot questions, the other holds long, meandering sessions.

Plenty rides along invisibly, too. System prompts accrete instructions over months and are paid for on every call. Tool and function definitions are serialised into each request whether the model uses them or not. Few-shot examples, retrieved passages stuffed in “just in case”, JSON schemas — all of it is input, all of it is metered, all of it is resent next turn. The countermeasures are unglamorous: summarise or compact history past a threshold instead of resending it whole, send only the tools a given call can plausibly need, set a context budget per feature and treat it as a limit, not a target. The tell-tale in a usage export is average input tokens per call creeping upward month over month while call volume stays flat.

Cache hits are a discount; cache misses are full price

Prompt caching exists because so much input repeats. When the beginning of your prompt — the system prompt, a long reference document, a fixed set of examples — is identical to a recent request’s, the provider can serve that prefix from cache instead of processing it again, and bills cached input at a reduced rate. The first request that writes the cache may be billed at the standard rate or a premium depending on the provider, and caches expire after a short window of inactivity, so sporadic traffic often misses entirely. Read the provider documentation before assuming the details; the mechanism is the same across providers but the rates and lifetimes are not, and the prompt caching guide from OpenAI and Anthropic’s equivalent documentation are the canonical descriptions.

The catch is that caching works on exact prefixes. One changed token early in the prompt — a timestamp in the system prompt, the user’s name interpolated at the top, a shuffled list of examples — invalidates the cache for everything after it, silently, at full price. The layout rule follows directly: stable content first, volatile content last; nothing that changes per request belongs at the top of the prompt. When you read your bill, look at the split between cached and uncached input. A workload that is obviously repetitive but shows a low cache-hit share does not have a pricing problem; it has a prompt-layout bug, and it is usually a one-line fix.

The calls nobody remembers making: retries, failures and side calls

Not every metered call is a user looking at an answer. Client libraries and gateways retry on timeouts and server errors, and when the original request actually completed on the provider’s side before the connection broke, the retry means you are billed twice for one visible answer. A generation that fails on your side — a client crash, a closed stream — may still have been metered for the tokens it produced before it died. Provider policies differ on the edge cases, but the safe operating assumption is blunt: tokens generated are tokens billed, whether or not anyone read them. The defence is bookkeeping, not hope: log the provider’s request IDs against your own, so a reconciliation pass can count duplicates instead of arguing about them.

Then there are the side calls, the ones behind the visible one. A chat reply may be accompanied by title generation, a rolling summary, a moderation pass, embeddings for retrieval, a reranker, a guardrail classifier — each small, each metered, and in aggregate capable of rivalling the feature they serve. Continuous evaluation harnesses in CI belong on the same list; a test suite that runs the full pipeline on every commit is a workload like any other. This is where model routing earns its keep as a design decision rather than an afterthought: a small, cheap model drafts, classifies and triages, and the large model is reserved for the final answer or the genuinely hard cases. Most side calls never needed the flagship model in the first place — they just inherited it as the default.

No attribution, no optimisation: tag first, cut second

An aggregate total cannot be optimised, because it does not say what anything is for. Attribution is the prerequisite: split usage by API key, by feature, by end user or customer, and by environment — production, CI, and somebody’s experimentation notebook are different budgets wearing one coat. Provider usage exports give you model, token counts by direction and cache status, and timestamps; the rest has to come from your own discipline — separate keys per feature, metadata on each call, logs that join a request to the user who caused it. Load the export into the LLM Usage Analyzer, and the shape of the spending usually becomes obvious within minutes: one feature dominating, one environment leaking, one model doing work far below its pay grade.

With attribution in place, guardrails become arithmetic. Set a budget per feature rather than one global number, alert at thresholds — half, four-fifths, all of it — and alert on the rate of change as well as the total: a doubling week over week at 3 a.m. is a bug or a leaked key, not organic growth, and it should wake someone up before the invoice does. Per-user quotas and maximum output lengths act as circuit breakers while you investigate. Then optimise strictly in the order the attribution gives you: the top feature’s prompt layout is worth an afternoon of work, the tenth feature’s is not — and before you ship a change, model it in the LLM cost calculator so the expected saving is a number you wrote down in advance, not a hope you check afterwards.

Sources and further reading

Frequently asked questions

Why did my bill double when my user count barely moved?

Usually because cost per user is not constant. Longer sessions re-bill the whole history on every turn, so input tokens grow much faster than call counts; a feature update that lengthens conversations, adds tools or retrieves more context raises the bill without adding a single user. A quiet shift in model mix — more traffic landing on a larger model — has the same signature. In a usage export, compare average input tokens per call across the two periods before you look at anything else.

Do failed or retried API calls still cost money?

Assume yes for any tokens actually processed or generated. A retry that duplicates a request the provider had already completed is billed as a second call, and a generation that dies on your side may still have metered the tokens it produced. Exact policies vary by provider and failure mode, which is why logging provider request IDs matters: reconciliation beats speculation when the invoice arrives.

What is the cheapest change with the biggest effect?

It depends on your attribution, but the usual winners are capping and compacting conversation history, stabilising prompt prefixes so caching actually hits, routing classification and drafting to a smaller model, and setting a maximum output length. Each attacks a different line of the bill — measure which line is largest in your export first, and fix that one.