LLM Token Pricing: Estimate API Cost Correctly
Estimate LLM API cost from input, cached input, output, sessions, and chat-history growth—then verify current provider rates before budgeting.
A model rate of $2.50 per million input tokens does not mean a 10-turn chat costs the same as ten isolated requests. Each later turn may resend the system prompt, retrieved documents, user messages, and prior responses. Cached prefixes, output length, tools, reasoning tokens, batch processing, and provider-specific fees can change the bill again.
This guide separates the arithmetic from the provider rules. It explains the exact planning model used by the DTC AI Tokens & Cost Calculator, includes a current pricing snapshot verified on July 1, 2026, and identifies details that still need confirmation on the provider invoice and official pricing page.
Quick Answer: Build the Estimate in Layers
- Count or estimate input and output tokens separately.
- Separate standard input from eligible cached input.
- Apply the correct per-million rate to each token category.
- Model every turn if conversation history is resent.
- Multiply per-session cost by sessions, retries, and environments.
- Add tool, storage, grounding, fine-tuning, or platform charges that the simple token model excludes.
- Verify model IDs, rates, context limits, cache rules, and batch eligibility before publishing a budget.
What LLM Tokens Mean
A token is a unit produced by a model-specific tokenizer. It may be a word, part of a word, punctuation, whitespace, or another byte sequence. The same text can produce different counts across providers, model families, languages, and tokenizer versions. Counting words is therefore not an exact tokenization method.
The DTC text estimator is intentionally approximate. It counts whitespace-separated words and multiplies by a selected planning factor: 1.3 for English, 2.0 for Spanish or French, 2.2 for German, 2.5 for code, and 3.5 for Arabic or Urdu. The result is rounded up. Use provider token-count endpoints or the tokenizer for the exact production model when accuracy matters.
Swipe sideways to compare columns.
| Category | What it can include | Typical billing treatment |
|---|---|---|
| Standard input | Instructions, user content, history, tool schemas | Input rate |
| Cached input/read | Repeated eligible prompt prefix | Reduced cached-input or cache-read rate |
| Cache write/storage | Creating or retaining reusable context | Provider-specific write and/or storage charge |
| Output | Visible response and sometimes reasoning tokens | Output rate |
| Tool/service usage | Search, grounding, code execution, storage | Separate unit or token charges may apply |
Core LLM API Cost Formula
From workload assumptions to budget
Do not choose a model rate before defining what each request sends and returns.
Define the workload
List system, document, user, history, output, and tool components.
Measure tokens
Use production usage fields or the exact model tokenizer where possible.
Classify billing
Separate standard input, cache reads, cache writes, output, and tools.
Model sessions
Account for turns, history growth, cache hit rate, and retries.
Apply current rates
Use the provider page for the deployed model and service tier.
Reconcile invoices
Compare the estimate with measured usage and update assumptions.
Current Pricing Snapshot Used by the Calculator
The following standard rates were verified from official provider documentation on July 1, 2026 and match selected entries in the calculator. They are USD per one million tokens. Pricing can change, and regional routing, long-context tiers, priority processing, or third-party platforms can differ.
Swipe sideways to compare columns.
| Model | Standard input | Cached input/read | Output | Important exclusion |
|---|---|---|---|---|
| OpenAI GPT-5.5 | $5.00 | $0.50 | $30.00 | Other service tiers and tool charges |
| OpenAI GPT-5.4 | $2.50 | $0.25 | $15.00 | Other service tiers and tool charges |
| Anthropic Claude Opus 4.6 | $5.00 | $0.50 cache hit | $25.00 | Cache writes cost more than base input |
| Anthropic Claude Sonnet 4.6 | $3.00 | $0.30 cache hit | $15.00 | Cache writes cost more than base input |
| Google Gemini 3.5 Flash | $1.50 | $0.15 | $9.00 | Explicit cache storage and grounding can add charges |
Pricing is more than input and output
Each provider exposes similar categories with different implementation rules.
OpenAI
Published model tables separate input, cached input, and output; Batch supports eligible asynchronous workloads.
- Verify model page
- Inspect cached_tokens usage
- Check tools and service tier
Anthropic
Prompt cache writes use premiums while cache hits use a reduced rate; inference geography can add a multiplier.
- 5-minute vs 1-hour write
- Cache read rate
- Global vs US inference
Gemini pricing can include cached-token rates, cache storage, and separate grounding or tool charges.
- Standard vs batch/flex
- Prompt-length tiers
- Grounding fees
Why Multi-Turn Chat Input Grows
A stateless API call does not remember earlier turns unless the application sends them again or uses a provider feature that preserves state. In the DTC simulation, each new turn includes static context, the current user message, and all previous user and response tokens. Output is modeled as a fixed number per turn.
Worked Example: Default GPT-5.4 Chat Simulation
Use the calculator defaults: GPT-5.4, 1,000 static system tokens, 500 user tokens per turn, 1,000 output tokens per turn, 10 turns, 50% of static context treated as cached, and 10,000 monthly sessions. The calculator uses $2.50/M standard input, $0.25/M cached input, and $15/M output.
Swipe sideways to compare columns.
| Component | Per session | 10,000 sessions | Cost |
|---|---|---|---|
| Standard input | 77,500 tokens | 775,000,000 tokens | $1,937.50 monthly |
| Cached input | 5,000 tokens | 50,000,000 tokens | $12.50 monthly |
| Output | 10,000 tokens | 100,000,000 tokens | $1,500.00 monthly |
| Total | 92,500 tokens | 925,000,000 tokens | $3,450.00 monthly |
Monthly cost components in the worked example
Output is only 10.8% of modeled tokens but 43.5% of cost because its rate is higher.
Standard input
775M tokens
Output
100M tokens
Cached input
50M tokens
The example excludes retries, tools, storage, regional multipliers, taxes, and provider rounding.
Prompt Caching: What the Calculator Simplifies
The calculator applies the selected cache percentage only to system plus document tokens, then bills that portion at the model's cached-input rate on every turn. This is a useful sensitivity model, but real caching depends on matching prefixes, minimum token thresholds, retention, cache creation, provider routing, and reported cache hits.
Swipe sideways to compare columns.
| Topic | DTC model | Production check |
|---|---|---|
| Eligibility | Chosen percentage of static context | Confirm minimums and prefix rules |
| Cache write | Not modeled separately | Anthropic and Google can charge writes or storage |
| Cache hit | Assumed on selected static tokens | Read actual usage fields |
| Retention | Not modeled | Check TTL or retention behavior |
| Invalidation | Not modeled | Changing early prompt content can reduce hits |
Batch Discounts and Asynchronous Work
The calculator applies a 0.5 multiplier to standard input, cached input, and output when Batch is enabled. Official OpenAI, Anthropic, and Gemini documentation currently describes 50% batch reductions for supported asynchronous workloads, but supported models, endpoints, cache interaction, and completion windows differ. Confirm the exact provider table before applying the toggle to a budget.
Costs the Simple Token Formula May Miss
- Reasoning tokens billed as output even when they are not displayed.
- Search, grounding, code execution, computer use, image, audio, or other server-side tools.
- Cache creation premiums, cache storage, and data-residency multipliers.
- Long-context or prompt-length pricing tiers.
- Third-party cloud or gateway markups and minimum charges.
- Retries, safety fallbacks, multi-model routing, evaluations, and moderation calls.
- Embedding, reranking, vector storage, and retrieval infrastructure in a RAG system.
- Taxes, currency conversion, committed capacity, or enterprise agreements.
Cost Optimization That Preserves Quality
- Measure usage by route, model, customer, and feature before optimizing.
- Place stable reusable content at the beginning when the provider cache requires a shared prefix.
- Trim irrelevant chat history and summarize older turns with explicit quality checks.
- Retrieve fewer, better RAG chunks instead of sending entire document collections.
- Set output limits and stop conditions appropriate to the task.
- Route simple workloads to a smaller model only after evaluation shows acceptable quality.
- Use batch processing for eligible work that does not need an immediate response.
- Reconcile forecasts with provider usage fields and invoices every release cycle.
Limitations and Verification Requirements
The calculator contains a fixed model and pricing table, an approximate word multiplier, simplified cache treatment, a uniform 50% batch toggle, and internal context-limit snapshots. Those values can become stale independently. It does not call provider billing APIs or tokenize text with each model's production tokenizer.
Sources to Verify or Cite
- OpenAI model comparison and pricing: https://developers.openai.com/api/docs/models/compare
- OpenAI prompt caching guide: https://developers.openai.com/api/docs/guides/prompt-caching
- Anthropic Claude pricing: https://platform.claude.com/docs/en/about-claude/pricing
- Google Gemini API pricing: https://ai.google.dev/gemini-api/docs/pricing
- The production API response usage fields and invoice for the exact deployed model.
Frequently Asked Questions
Is one token equal to one word?
No. Tokens are model-specific text units. A word can be one token, several tokens, or part of a larger token, and whitespace and punctuation can also consume tokens.
Is the DTC text token estimate exact?
No. It multiplies whitespace-separated words by a language or content factor. Use the provider token counter or exact tokenizer for production measurement.
Why are output tokens often a large share of cost?
Many model tables price output above standard input. A relatively small output can therefore contribute materially to the bill.
Why does chat-history cost grow faster than turn count?
If every turn resends all prior messages, earlier tokens are billed repeatedly. The sum of resent history forms a triangular series and grows quadratically with the number of turns.
Does a 50% cache setting guarantee half-price input?
No. It is a planning assumption. Real savings depend on eligible tokens, cache hits, write or storage charges, retention, and the provider's pricing rules.
Does prompt caching reduce output cost?
Usually it changes the billing of repeated input, not generated output. Check the provider table for the exact model and service tier.
Does the calculator include reasoning tokens?
It models the output-token value you enter. If a provider bills additional reasoning tokens as output, include them in measured usage or add a separate allowance.
Does the Batch toggle always apply?
No. The calculator applies a simple 50% multiplier. Confirm that the provider, model, endpoint, workload, and completion window qualify for batch pricing.
How should retries be budgeted?
Track attempted calls and billable usage, not only successful user responses. Add an observed retry and failure factor to monthly sessions.
Are context-window limits a cost limit?
No. A context window limits what can fit in a request or interaction; billing still depends on processed token categories and provider rules.
How often should pricing assumptions be refreshed?
Refresh before publishing a comparison, changing models, signing a capacity commitment, or approving a material budget. Also reconcile against invoices regularly.
What is the best source for actual cost?
The provider's usage fields and invoice for the exact model and endpoint are authoritative for consumed usage. Use official pricing pages to explain and forecast those charges.
Final Summary
A credible LLM budget starts with workload shape, not a model price alone. Measure standard input, cached input, output, history growth, sessions, and non-token services separately. Use the DTC calculator to test assumptions, then replace estimates with production usage and current official rates.
Written by
Do The Calculation Team
Do The Calculation Editorial Board
The Do The Calculation Editorial Board is comprised of software engineers, finance analysts, and technical contributors focused on building clean, accurate, and easy-to-use calculator tools.
Reviewed & Verified By
Dr. James Callahan, PhD
Systems & Computing Advisor
Network architect and computing systems designer. Dr. Callahan reviews our subnet calculators, AI token pricing matrices, and disk storage estimators to align calculations with actual infrastructure standards.