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 every listed model.
By StackCalcs · Updated · Sources checked
Start with request volume and prompt shape
LLM APIs charge different rates for uncached input, cached input, cache writes, and output. Export request counts and average input and output tokens per request from your production logs for one billing period, plus the share of each prompt that is a stable, cacheable prefix.
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. In the LLM API Cost Calculator, enter about 1,667 requests per day for 30 days, 2,000 input tokens, 250 output tokens, a 20% cacheable prefix, and a 100% hit rate. The tool prices every listed model on that workload, ranks them, and shows each cost component for the model you select.
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 with cache writes, batch discounts, and long-context bands. Cache storage, tools, regional processing, taxes, discounts, and free allowances remain outside the result.
FAQ
Does the calculator ask me to enter vendor rates?
No. Every listed model is priced from its verified uncached-input, cached-input, cache-write, output, batch, and long-context rates, and the model you select is highlighted.
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/pricing
- https://platform.claude.com/docs/en/about-claude/pricing
- https://ai.google.dev/gemini-api/docs/pricing