Practical guide
How to Calculate Monthly LLM API Cost from Token Usage
Turn request logs into monthly LLM API cost using uncached input, cached input, and output tokens across three model options.
Updated · Sources checked
Start with token totals, not request count
LLM APIs charge different rates for uncached input, cached input, and output. Export those three totals from your production logs for one billing period. If you only have averages, multiply requests by average tokens per request, then keep input and output separate.
Suppose a support assistant receives 50,000 requests per month. Each request averages 1,600 uncached input tokens, 400 cached input tokens, and 250 output tokens. Enter 80 million uncached input tokens, 20 million cached tokens, and 12.5 million output tokens in the LLM API Cost Calculator. Select GPT-5, Claude Sonnet 4, or Gemini 2.5 Pro; the tool applies its verified rate card and shows each component.
This example reveals why a single “cost per million tokens” is misleading. Output may represent only 11% of total tokens yet contribute much more because output rates differ from input rates.
Forecast a new workload
For a product without logs, estimate three cases. Vary request volume, context length, answer length, and cacheable prefix independently. A concise calculation is:
monthly tokens = requests × average tokens per request
Run the calculator once for expected traffic, then again with longer outputs and a lower cache-hit share. The gap is a useful budget reserve.
The tool includes token charges only. Batch pricing, long-context bands, cache writes or storage, tools, regional processing, taxes, discounts, and free allowances remain outside the result.
FAQ
Does the calculator ask me to enter vendor rates?
No. You choose one of the three listed models, and the calculator uses its verified uncached-input, cached-input, and output rates.
Where should token counts come from?
Use API usage fields or an aggregated observability export. Sampling a few prompts often misses system messages, retrieved context, retries, and unexpectedly long answers.
Official sources
- https://developers.openai.com/api/docs/models/gpt-5
- https://platform.claude.com/docs/en/about-claude/pricing
- https://ai.google.dev/gemini-api/docs/pricing