# 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.

---

- **Canonical URL:** https://dothecalculation.com/blog/tech/llm-tokens-pricing-guide
- **Category:** AI & Tech Development
- **Author:** Do The Calculation Team
- **Published:** 2026-06-05
- **Last updated:** 2026-07-01
- **Reading time:** 19 min read
- **Publisher:** Do The Calculation (https://dothecalculation.com)
- **Methodology:** https://dothecalculation.com/methodology

---

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.

**DTC token estimate**

```
Estimated tokens = ceiling(
  words x language multiplier
)
```
- This is a planning heuristic, not model tokenizer output.
- Images, audio, documents, tool schemas, and hidden provider overhead need separate accounting.

**Token categories commonly visible on an API bill**
| 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

**Token cost per request or session**

```
Cost = input cost + cache-read cost + output cost

input cost = standard input / 1,000,000 x input rate
cache-read cost = cached input / 1,000,000 x cached rate
output cost = output / 1,000,000 x output rate
```
- Keep token categories mutually exclusive; do not count cached tokens again as standard input.
- Rates must use the same currency and per-million basis.
- Add non-token charges outside this formula.

**Monthly planning cost**

```
Monthly cost = Cost per session x Monthly sessions
```
- Use attempted calls when retries and failed workflows still consume billable usage.
- Separate production, staging, evaluations, and batch jobs if their patterns differ.

_[Figure: From workload assumptions to budget — Do not choose a model rate before defining what each request sends and returns.]_

## 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.

**Selected verified rates as of July 1, 2026**
| 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 |

_[Figure: Pricing is more than input and output — Each provider exposes similar categories with different implementation rules.]_

## 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.

**DTC total input across n chat turns**

```
Total input = n x static-and-user tokens
  + history tokens x n x (n - 1) / 2

history tokens = user tokens + response tokens
```
- Static context = system prompt tokens + document tokens.
- The triangular term represents prior message history resent across later turns.
- This is quadratic growth when the full history is appended without trimming or summarization.

## 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.

**Calculator-aligned session and monthly cost**
| 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 |

_[Figure: 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.]_

Tool: [Estimate LLM Tokens and API Cost](https://dothecalculation.com/calculators/ai-tokens-calculator) — Model text-token heuristics, static and dynamic context, cache percentage, chat turns, monthly sessions, model rates, and a simplified batch discount.

## 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.

**Planning model vs provider reality**
| 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.

> **Verify before publishing or purchasing capacity** — Model names, rates, context limits, tokenizers, caching rules, and supported service tiers can change. Confirm the deployed model on the official provider pricing and model pages, then compare the forecast with measured API usage.

## 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.

---

_Source: [Do The Calculation](https://dothecalculation.com/blog/tech/llm-tokens-pricing-guide). Quote freely with attribution and a link to this page._
