Costs that surprise people building on LLMs
The per-token price is the number everyone checks and rarely the one that hurts.
A prototype costs a few pounds a month. Then it goes to production and the bill is a surprise. The causes are consistent.
Output costs several times input
Most providers price output tokens well above input. A prompt that encourages long answers is expensive twice — once for the tokens, once for the latency.
"Answer in at most three sentences unless asked to expand" is a constraint with a line-item effect.
Retries multiply everything
A call that fails validation and retries costs twice. One that retries three times costs four times, and it is usually the hardest inputs — the ones near a limit — that retry.
Retries rarely appear in an estimate because the estimate assumes the happy path. Measure the real rate before forecasting anything.
Agents multiply harder
An agent loop makes many calls per task, and each one carries the accumulated conversation. Cost grows faster than linearly with the number of steps because the context grows with every step.
A ten-step agent is not ten times a single call. It is frequently thirty or fifty.
The system prompt is charged every time
A two-thousand-token system prompt on every request, a million times, is two billion tokens. This is the one that catches people, because the system prompt feels like configuration rather than payload.
Prompt caching helps substantially — but only if the prefix is stable. Interpolating a timestamp or a user id near the top of the prompt invalidates the cache on every call, and it is an easy thing to do without noticing.
What actually controls it
Route by difficulty. Most requests do not need the largest model. A cheap model with a fallback to an expensive one, triggered by a confidence check, is usually the single biggest saving available.
Cache the deterministic parts. Identical inputs recur far more than people expect.
Cap the output. Both by instruction and by max_tokens. The instruction is ignored occasionally; the parameter is not.
Set a per-user limit before launch, not after. One user with a script can generate a month's budget in an afternoon, and the incident report writes itself.
The estimate to actually make
Cost per task, not per token — including retries, including the agent's extra steps, including the system prompt.
Then multiply by realistic volume rather than the volume in the plan. The gap between those two is where the surprise lives.