TokenPad

How-to · 8 min · 6 steps

How to calculate LLM API costs

Work out what an LLM API will actually cost: measuring real token counts, input-to-output ratio, caching, and the compounding costs budgets miss.

Published August 4, 2026

Most LLM cost estimates are wrong in the same direction, for the same three reasons: the token counts were guessed, the output pricing was ignored, and the workload compounds in a way per-request arithmetic misses.

This produces a number you can defend. It takes about fifteen minutes if you have production logs and about half an hour if you do not.

  1. Measure a real request, do not estimate it

    Take an actual production payload — the whole thing, including system prompt, conversation history, tool definitions and retrieved documents — and count it. The rule of thumb everyone uses describes English prose, and most payloads are not English prose.

    LLM Token CounterReal BPE tokenization, not characters ÷ 4. Shows which counts are exact and which are estimates.
  2. Get your input-to-output ratio

    Median input tokens divided by median output tokens. Summarisation and classification run 20:1 or higher; generation and code-writing approach 1:1. This single number decides which model is cheapest for you, and the ranking inverts between the two extremes.

  3. Price input and output separately

    Output typically costs four to six times input because it is generated one token at a time. A model with a cheaper headline input rate can be more expensive in production if it answers at length.

    LLM API Cost CalculatorRequests per month in, dollars out. Input, cached input and output priced separately.
  4. Work out your cacheable share

    Any stable prefix — system prompt, tool schemas, a fixed document — bills at roughly a tenth of the base rate once cached. A chatbot with a 2,000 token system prompt and 200 tokens of user text is around 90% cacheable, and that is most of the input line of the bill.

    Prompt Cache Structure CheckerFinds cache-busting content and measures the prefix that survives it.
  5. Model the compounding, if your workload has any

    Conversations resend their history every turn, so input grows with the square of the turn count. Agent loops do the same. A per-request estimate understates a chat product by three or four times.

    Chatbot Conversation Cost CalculatorHistory is resent every turn, so cost grows quadratically. Most budgets miss this entirely.
  6. Add growth and check the run rate

    Project twelve months at your measured growth rate, not your target. The month twelve run rate is the number for a planning meeting; month one is the number that gets you an uncomfortable conversation in the autumn.

    Annual LLM Budget PlannerWorkload breakdown plus twelve-month projection with growth compounding.

What goes wrong

Forgetting reasoning tokens

Reasoning models bill their internal thinking as output even though you never see it. At high effort the hidden portion can be several times the visible answer, so every budget built on answer length is wrong.

Comparing providers with one token count

Each provider tokenizes with its own vocabulary. Anthropic has stated that the tokenizer introduced with Claude 4.7 produces roughly 30% more tokens for identical text than its predecessor. A model priced 20% lower but tokenizing 30% denser is more expensive, not cheaper.

Averaging across workloads

Spend is almost always concentrated in one endpoint. Averaging hides it, and optimising the small workloads is satisfying and pointless.

Frequently asked questions

What is a realistic cost per user?
Entirely dependent on usage shape, which is why it is worth modelling rather than benchmarking. The figure that breaks products is not the average user but the heavy decile, who commonly use five times the mean.
How much can I realistically save?
On a workload nobody has optimised, forty percent is a normal first pass: caching, payload minification and a shorter system prompt account for most of it. Batch processing adds roughly half off anything that is not blocking a user.

Tools for this

Read next