Calculate the token bill without double-counting
Multiply token counts by the matching per-million rates in the table above. Divide by one million because providers quote those rates per million tokens, not per token.
Token subtotal = (uncached input × input rate + cached reads × cached-input rate + output × output rate) / 1,000,000.
If a provider charges separately for cache creation, add cache-write tokens at the applicable write rate. Keep cache writes separate from uncached input when the write rate replaces the ordinary processing charge. Then add storage, paid tools, retrieval, or other metered services as applicable.
Provider responses may report cached tokens as a subset of total input. In that case, subtract cache reads from total input before applying the uncached rate. Do not bill those same tokens in both buckets.
The chart compares input and output unit prices. The table adds cached reads, but neither includes every provider-specific surcharge. Check the OpenAI pricing page, Anthropic pricing page, and Google AI pricing page for model-specific dimensions and official sources. The selected models illustrate the arithmetic; they are not a claim that older models are today’s best choice.
Worked workloads
| Monthly workload | Uncached input | Cache reads | Output |
|---|---|---|---|
| Support bot | 50M | 0 | 10M |
| Coding assistant | 30M | 70M | 20M |
| Document assistant | 40M | 160M | 15M |
| Pricing data: How we verify → | |||
For the support bot, multiply the selected model’s input rate by 50 and output rate by 10, then add them. For the coding assistant, multiply input by 30, cached input by 70, and output by 20. The document assistant uses multipliers of 40, 160, and 15.
These examples assume the cache reads actually qualify and exclude cache creation, storage, tools, and taxes. They are workload definitions, not provider quotes. Use the token cost calculator with the appropriate token mix; the compact calculator above intentionally uses a fixed uncached split.
Turn a token estimate into a monthly budget
- Measure real requests. Capture system instructions, retrieved passages, conversation history, tool results, and completion usage from the API response. Word-to-token ratios are rough estimates; code and non-English text can differ substantially.
- Count every call in a task. Agents may plan, call tools, retry, and summarize. A session is not necessarily one model request.
- Separate normal and expensive cases. Compare median usage with long sessions and high-output cases. Include failed attempts and fallback models.
- Forecast volume. Multiply measured tokens per completed task by expected monthly task counts. Model ordinary demand, higher adoption, and unusually heavy usage separately.
- Add non-token charges and headroom. Track cache writes, cache storage, search, execution tools, infrastructure, and applicable taxes. A 10–30% contingency is a planning choice, not a provider discount.
- Reconcile against billing. Compare your first production week’s estimate with the provider dashboard. Investigate discrepancies before raising limits.
Reduce spend where it actually accumulates
If output dominates, request concise answers and cap agent turns. If repeated input dominates, stabilize the prefix and measure cache-hit usage; our cached-token guide explains the trade-offs. If history dominates, summarize it or retrieve only relevant passages.
Evaluate cheaper models on the same acceptance criteria before routing production traffic. Measure cost per accepted task, including retries and human review, rather than choosing solely by the lowest input rate.
For asynchronous work, verify the exact model’s batch rate and supported features. Do not assume batch and caching discounts stack or apply a generic percentage to tools and storage.
Open-model comparison: If your task can run on an open model, include Novita’s hosted model catalog in your evaluation. Check the available model, rate, region, and quality before switching.
Affiliate disclosure: we may earn a commission through this link, at no extra cost to you.
FAQ
What is the simplest AI API cost formula?
Multiply uncached input, cache reads, and output tokens by their respective per-million rates, add the results, and divide by one million. Add separately billed cache writes and non-token services when applicable.
Can I estimate cost from word count?
Only approximately. Use your model’s tokenizer before launch and actual API usage records once traffic starts.
Are cached tokens always discounted automatically?
No. Eligibility, minimum prefix length, retention, write charges, and storage fees depend on the provider and model.
Is the cheapest token rate always the cheapest deployment?
No. Compare total cost per accepted task, including retries, tool calls, latency requirements, and human review.