New Tool Radar

AI Concepts

How to Estimate an LLM API Bill from Token Counts and Pricing

Work out what an LLM API call will cost from the token counts and the pricing page, before the invoice arrives.

Schematic illustration with three step boxes: count input and output, read the pricing page, and multiply and compare.

API cost has two distinct phases: prefill, where the model reads your prompt, and decode, where it generates one token at a time. Output tokens cost five to ten times more than input tokens, and cached input tokens are often free or heavily discounted. An estimate needs all three numbers: input tokens, output tokens, and the cached share.

Before you start

Token counts for a typical request, the provider’s pricing page, and the number of requests per day.

Count input and output separately

Count the input tokens and the expected output tokens as two numbers, not one total. Output tokens cost far more than input, so a short prompt with a long reply costs more than a long prompt with a short reply.

Count the cached share of the input separately: a 4,000-token static prefix that hits the cache may be billed at a discount or not at all, depending on the provider.

Read the pricing page for your model

Open the provider’s pricing page and write down the per-million-token prices for input, cached input and output for the exact model you use. Prices differ by model tier: budget, mid-tier and premium models sit in different ranges.

Do not use a price from a guide or a blog post: pricing pages change, and an old price makes the whole estimate wrong.

Multiply, add the volume, and compare

Multiply each token count by its price, add the three parts, and multiply by the number of requests per day. Compare the result with the next cheaper model: a budget model that needs two retries can outspend a mid-tier model that answers correctly the first time.

Recheck the estimate monthly, or whenever the provider changes prices or you change models.

Practice check: fictional Maple Corner bot, 1,000 calls a day

The table below is fictional practice material, worked out by hand from the stated token counts and example prices. It is the expected result for the practice workload, not a real invoice.

Part Tokens per call Price per million Cost per day
Cached input 4,000 $0.50 $2.00
Fresh input 120 $3.00 $0.36
Output 400 $15.00 $6.00
Total 4,520 Mixed $8.36

The daily cost is $8.36: $2.00 for cached input, $0.36 for fresh input and $6.00 for output. Output is 72 percent of the bill even though it is only 9 percent of the tokens.

Expected result. UNTESTED: the prices and totals in the practice table are example figures worked out by hand, not a real invoice. Count your own input, cached and output tokens, read the current pricing page for your model, and multiply before you commit to a volume.

Limits

  • Prices on the pricing page are the only prices that count: do not trust a figure copied into a guide.
  • Retries, tool calls and long conversations all add tokens that a single-call estimate misses.

Sources

See all