Guide

How an LLM API bill is calculated

An API bill is the sum of a few lines: each line’s tokens times its price. This guide works one month through on a published price list, from uncached input to cache writes, cache reads, output and batch, shows when prompt caching saves money and when it costs more, and lists what such a total leaves out.

Written Nov 23, 2026 · Figures reviewed Nov 23, 2026 · Every figure links to its source.

The lines of a bill

A language model’s price list prices tokens, usually per million. Each request’s tokens fall on four lines:

  • Input: the prompt’s tokens that aren’t read from a cache.
  • Cache write: prompt tokens stored in the seller’s prompt cache so that later requests can read them. On price lists that price writes, the price can depend on how long the cache keeps them.
  • Cache read: prompt tokens read back from the cache.
  • Output: the tokens the model generates.

The prompt is the sum of the first three lines. A cached token is billed once, on the line it falls on, never as input as well. A month’s cost is then

cost = Σ (tokens on the line × the line’s price ÷ 1,000,000)

Which price a line takes depends on the request: the prompt’s length (some price lists charge more past a threshold), batch or not, the service tier, the cache’s length. Each is a row of its own on the price list, not a discount to apply on top of another.

A month, worked through

Take this workload. It is an assumption, chosen so that the arithmetic is easy to follow, not a measured or typical one:

  • 20,000 requests a month;
  • each prompt 25,000 tokens: 20,000 that are the same in every request (instructions, tool definitions, reference documents) and 5,000 new ones;
  • each answer 800 tokens;
  • the shared 20,000 tokens written to the cache on one request in 20, and read from it by the other 19.

Priced at the standard prices of GPT-6.2 Sol on the OpenAI API (global, USD), with its 30-minute cache:

LinePrice / 1M tokens
Input$2.00
Cache write· 30-minute cache$2.50
Cache write· 12-hour cache$5.00
Cache read$0.10
Output$10.00

One request, three ways

LineNothing cachedWrites the shared partReads the shared part
Input$0.050 · 25,000$0.010 · 5,000$0.010 · 5,000
Cache write—$0.050 · 20,000—
Cache read——$0.002 · 20,000
Output$0.008 · 800$0.008 · 800$0.008 · 800
Total$0.058$0.068$0.020

A request that writes costs $0.068 instead of $0.058: writing the shared part costs 25% more than sending it. A request that reads costs $0.020: the shared part is 95% cheaper read than sent.

The month

The month with the cache
LineTokensPrice / 1M tokensCost
Input100,000,000$2.00$200.00
Cache write20,000,000$2.50$50.00
Cache read380,000,000$0.10$38.00
Output16,000,000$10.00$160.00
Total$448.00

Without the cache, the same month is 500,000,000 input tokens at $2.00 per million and the same output: $1,160.00. The cache saves 61.4%.

Cached tokens are 95% cheaper than input here, yet the bill falls 61.4%: the cache only touches the shared part of the prompt. Each request’s 5,000 new tokens and the output, $360.00 of the $448.00, cost the same with or without it, and every write costs more than sending. “95% off cached input” is a discount on one line, not on the bill.

When prompt caching saves money

A write pays for itself through the reads that follow it. Writing a shared part once and reading it n times costs less than sending it n + 1 times when

n × (input − read) > write − input, that is, n > (write − input) ÷ (input − read)

  • With the 30-minute cache: ($2.50 − $2.00) ÷ ($2.00 − $0.10) = 0.26: one reuse already saves.
  • With the 12-hour cache: ($5.00 − $2.00) ÷ ($2.00 − $0.10) = 1.58: it takes 2 reuses to save.

How many reuses a write gets is what a price list can’t tell you. It depends on how often requests with the same beginning arrive while the cache still holds it, and on the seller’s own rules for what a cache matches and how long it lasts, which are in its documentation, not in its prices.

Monthly cost by requests per cache write
Requests per cache write30-minute cache12-hour cache
No cache$1,160.00$1,160.00
1 (every request writes)$1,360.00$2,360.00
2$880.00$1,380.00
5$592.00$792.00
20$448.00$498.00
100$409.60$419.60

The same workload each month; only how often the shared part is written changes. Figures below the no-cache month are in bold.

If every request writes (the shared part changes each time, or the cache is gone by the next request), caching costs $1,360.00 a month, 17.2% more than not caching. A longer cache costs more per write, so it is worth its price only where it turns writes into reads: the 12-hour cache at one write per 20 requests ($498.00) costs less than the 30-minute cache at one write per 5 ($592.00), and more than the 30-minute cache at one per 20 ($448.00).

Long prompts: a threshold reprices the whole request

This price list prices a request by its prompt’s length: past 272,000 tokens, the request pays its long-context prices for all its tokens, not only those past the threshold. Nothing cached, the same 800-token answer:

PromptInputOutputPer request
272,000$0.544 · $2.00 / 1M$0.008 · $10.00 / 1M$0.552
300,000$1.20 · $4.00 / 1M$0.012 · $15.00 / 1M$1.212

10.3% more tokens cost 119.6% more. A prompt that would just cross the threshold costs 54.5% less kept under it.

Batch: prices of its own, not a discount to stack

Batch requests, where a price list has them, are priced by their own rows. GPT-6.2 Sol’s list on the OpenAI API states a batch price for each of the four lines; with the same cache shares, the month is $224.00:

The month as batch requests
LineTokensPrice / 1M tokensCost
Input100,000,000$1.00$100.00
Cache write20,000,000$1.25$25.00
Cache read380,000,000$0.050$19.00
Output16,000,000$5.00$80.00
Total$224.00

That this is half of $448.00 is because each of these batch prices is half its standard one, not a rule: the total comes from the four stated prices. The same cache shares are kept only to show the arithmetic; how often a batch job’s requests share a cache is the seller’s to say.

Claude Sonnet 5.5 on the Claude API has the same four standard prices, so the same month costs $448.00 there too. Its batch prices, as its price list gives them, cover only some lines: there is no batch price for its cache reads or writes. A batch month there adds up only in part:

The counterexample's batch month
LineTokensPrice / 1M tokensCost
Input100,000,000$1.00$100.00
Cache write20,000,000Not stated—
Cache read380,000,000Not stated—
Output16,000,000$5.00$80.00
Stated lines$180.00

Billing the lines without a batch price at their standard prices, as the calculator does (it says the batch price isn’t applied to them), gives $268.00. Discounting them as the input is discounted would give $224.00, a figure no price list states. Ask the seller before counting on it.

What such a total leaves out

  • Tools a request uses (web search, code execution, file search…) and their own fees: the ledger counts tokens only.
  • Cache storage: where a seller bills a cache for how long it keeps it, that is a line of its own.
  • Failed and retried requests: the tokens a seller bills for them count like any others; add your retry rate to the request count.
  • Reasoning: tokens a model generates while it reasons are tokens it generates; count them in your output where its seller bills them as output.
  • Tax, minimum spend, credits, negotiated discounts and commitments.
  • Currency: the prices are in the offering’s currency (USD here); converting is a separate step at a dated rate.
  • A price that isn’t stated is never zero. The calculator leaves out an offering that doesn’t sell what a scenario asks for, or whose window a prompt passes, rather than pricing it.

With any of these in play, the figure is a subtotal of the lines listed, not the bill.

Check it yourself

  • Open this month in the calculator → It prices the same workload on every offering at today’s prices, filtered to this one.
  • Each price links to the page it was read from (the dot beside it), with the day it was last checked.
  • The figures are worked out when the site is built, from the same prices and the same code as the calculator. If the example’s price list stops stating a line, this page says so instead of keeping an old figure.
  • Reviewed on Nov 23, 2026 against data release rel_20261123_005634_dc492f63d151: $1,160.00 without the cache, $448.00 with it, $224.00 as batch requests.