Cost equals input tokens times the input rate plus output tokens times the output rate, both per million. For agent and chat workloads you must add the repetition term, because context is re-sent every turn, add cache writes at 1.25x or 2x base input, and apply the cache-read rate of 0.1x base input to the repeated prefix. On Opus 5, Sonnet 5, and Fable 5 an English word is about 1.8 tokens, not 1.3, because those models use the tokenizer introduced with Opus 4.7.
- Base formula:
(in / 1M x rate_in) + (out / 1M x rate_out). - For multi-turn work, the input term is cumulative, not per-turn.
- Cache reads are 0.1x base input. Cache writes are 1.25x for five minutes and 2x for an hour.
- On Opus 5, Sonnet 5, and Fable 5, one English word is about 1.8 tokens. On Sonnet 4.6 and Haiku 4.5 it is about 1.33.
- Output is five times the price of input but usually under a tenth of the volume.
- For anything you will run at volume, use
/v1/messages/count_tokens, not a word ratio.
The formula
cost = (input_tokens / 1_000_000) x input_rate
+ (output_tokens / 1_000_000) x output_rate
cost = SUM over turns of:
(new_tokens_this_turn / 1M) x cache_write_rate
+ (repeated_prefix_tokens / 1M) x cache_read_rate
+ (output_tokens / 1M) x output_rate
The second formula is the one that matches an invoice. New content on each turn is written into the cache once, the accumulated prefix is read back cheaply on every subsequent turn, and output is billed normally.
The rates
Per-million token rates from the Anthropic pricing page, checked 7 August 2026.
| Model | Input | 5m cache write | 1h cache write | Cache read | Output |
|---|---|---|---|---|---|
| Claude Fable 5 | $10.00 | $12.50 | $20.00 | $1.00 | $50.00 |
| Claude Opus 5 | $5.00 | $6.25 | $10.00 | $0.50 | $25.00 |
| Claude Sonnet 5 | $3.00 | $3.75 | $6.00 | $0.30 | $15.00 |
| Claude Haiku 4.5 | $1.00 | $1.25 | $2.00 | $0.10 | $5.00 |
The cache multipliers are fixed
You do not have to memorize four numbers per model. Caching is a set of multipliers on base input, and they are the same for every model.
Prompt caching multipliers relative to base input.
| Operation | Multiplier | Break-even |
|---|---|---|
| 5-minute cache write | 1.25x | Pays off after one cache read |
| 1-hour cache write | 2x | Pays off after two cache reads |
| Cache read | 0.1x | n/a |
Other modifiers stack on top of these. The Batch API takes 50 percent off input and output. Setting inference_geo to us applies a 1.1x multiplier to every category. The 1M context window carries no premium: a 900K-token request is billed at the same per-token rate as a 9K one.
Estimating token counts
You need a token count before you can price anything. In 2026 the conversion changed, and most calculators on the internet have not noticed: Claude Opus 4.7 introduced a new tokenizer that produces roughly 30 percent more tokens for the same text, and Opus 5, Sonnet 5, and Fable 5 all use it.
Conversion ratios derived from the published context-window equivalences in the Anthropic models overview.
| Sonnet 4.6, Opus 4.6, Haiku 4.5 | Opus 5, Sonnet 5, Fable 5 | |
|---|---|---|
| Tokens per English word | ~1.33 | ~1.80 |
| Characters per token | ~3.4 | ~2.5 |
| Words in a 1M context window | ~750,000 | ~555,000 |
| A 1,000-word document | ~1,330 tokens | ~1,800 tokens |
| A 300-line source file | ~3,000 tokens | ~4,000 tokens |
| A 5,000-line test log | ~40,000 tokens | ~54,000 tokens |
Ratios are for back-of-envelope work. For anything you will run repeatedly, count properly. The endpoint is free and exact.
curl https://api.anthropic.com/v1/messages/count_tokens \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-5",
"messages": [{"role": "user", "content": "How many tokens is this?"}]
}'
Minified code, non-English text, and JSON all tokenize worse than prose, sometimes by a factor of two. Pass the real payload, not a sample.
Three worked examples
A single chat exchange
You send 800 words of context plus a question, and get 400 words back. On Sonnet 5 at standard rates, using 1.8 tokens per word:
input = 1,050 words x 1.8 = ~1,890 tokens
output = 400 words x 1.8 = ~720 tokens
cost = (1_890 / 1M) x $3.00 + (720 / 1M) x $15.00
= $0.0057 + $0.0108
= $0.017
Under two cents. This is why single-shot chat pricing feels free and gives people entirely the wrong intuition for what follows.
A RAG endpoint
You retrieve 6 chunks averaging 500 tokens, add a 400-token system prompt and a 50-token question, and generate 300 tokens. On Sonnet 5, per request:
input = 3_000 + 400 + 50 = 3_450 tokens
output = 300 tokens
cost = (3_450 / 1M) x $3.00 + (300 / 1M) x $15.00
= $0.0104 + $0.0045
= $0.0149 per request
at 100_000 requests/month = ~$1_490
Caching the 400-token system prompt saves about $108 a month, which is a rounding error. The retrieved chunks are what cost money and they change every request, so they never cache. The lever that actually works here is the Batch API: if the workload tolerates latency, 50 percent off takes the same month to about $745.
An agent session
Twenty turns. Context starts at 20k and grows by 5k a turn; 800 output tokens per turn. On Sonnet 5 with a five-minute cache:
new content (cache write) = 20_000 + (19 x 5_000) = 115_000 tok @ $3.75/M = $0.431
repeated prefix (cache read, cumulative) ~ 1_235_000 tok @ $0.30/M = $0.371
output = 20 x 800 = 16_000 tok @ $15.00/M = $0.240
total = $1.04
Scale that up honestly. A working day of similar sessions, say twelve of them, is about $12.50 on Sonnet 5 and roughly $21 on Opus 5. That is the same order as the $13 per developer per active day Anthropic reports across enterprise Claude Code deployments, which is a good sign the model is right.
The line items people forget
A real bill has more rows than input and output. None of these dominate on their own, and together they routinely add 10 to 20 percent to a naive estimate.
Charges outside the base token formula, August 2026.
| Item | Cost |
|---|---|
| Tool-use system prompt, Opus 5 | 286 input tokens, or 406 with a forced tool choice |
| Tool-use system prompt, Sonnet 5 | 354 input tokens, or 474 with a forced tool choice |
| Bash tool definition, Opus 5 | +325 input tokens |
| Text editor tool definition | +700 input tokens |
| Computer use | +466 to 499 system prompt tokens, +735 per tool definition |
| Thinking tokens | Billed as output tokens, at the output rate |
| Web search | $10 per 1,000 searches, plus tokens for the results |
| Web fetch | No additional charge beyond the fetched tokens |
| Code execution | 1,550 free hours per org per month, then $0.05 per hour per container |
| Managed Agents session runtime | $0.08 per session-hour, on top of tokens |
| Fast mode, Opus 5 | $10 in and $50 out per million |
One ceiling worth knowing: max output is 128K tokens on Opus 5, Sonnet 5, and Fable 5, and 64K on Haiku 4.5. A single maxed-out Opus 5 response is 128,000 tokens at $25 per million, or $3.20 for one reply.
Sanity checks
- If your estimate for an agent session ignores repetition, it is low by 3 to 10 times.
- If it ignores caching, it is high by 3 to 4 times.
- If you priced words at 1.33 tokens on Opus 5 or Sonnet 5, it is low by about 35 percent.
- If output dominates your total, either you are not modelling a coding workload or thinking is doing it. Check the effort level.
- If a number looks impossibly small, you likely priced one turn instead of the whole session.
- If it looks impossibly large, check whether the Batch API applies. Fifty percent is a lot of arithmetic to leave on the table.
Questions people ask
Multiply input tokens by the input rate and output tokens by the output rate, both per million. For multi-turn work you must sum across turns, because context is re-sent each time, charge new content at the cache-write rate of 1.25x base input, and charge the repeated prefix at the cache-read rate of 0.1x base input.
It depends on the model. Opus 5, Sonnet 5, and Fable 5 use the tokenizer introduced with Opus 4.7 and average about 1.8 tokens per English word, or roughly 2.5 characters per token. Sonnet 4.6, Opus 4.6, and Haiku 4.5 average about 1.33 tokens per word, or roughly 3.4 characters per token.
A cache read is 0.1x the base input rate. A five-minute cache write is 1.25x base input and pays for itself after one read; a one-hour write is 2x and pays for itself after two reads. On Sonnet 5 that is $0.30 per million read against $3.00 base input.
Per million tokens as of August 2026: Fable 5 at $10 in and $50 out, Opus 5 at $5 and $25, Sonnet 5 at $3 and $15, and Haiku 4.5 at $1 and $5. Sonnet 5 is on introductory pricing of $2 and $10 through 31 August 2026.
Usually because you priced a single turn rather than the cumulative session, or because you used the old 1.33 tokens-per-word ratio on a model that uses the newer tokenizer. Thinking tokens billed at the output rate are the third common omission.
A request that errors before processing is not billed. One that returns a partial response before failing bills for what was processed. Streaming responses you disconnect from still bill for what was generated.
Yes. POST to /v1/messages/count_tokens with the same model and messages you plan to send, and it returns an exact input_tokens figure. Word ratios are for back-of-envelope work only; the endpoint is the right tool for anything you will run at volume.
No. Claude 4.6 and later models include the full 1M window at standard pricing, with no premium for tokens beyond 200K. Prompt caching and Batch API discounts apply across the whole window at standard rates.
Sources
Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.