Skip to content

$ cat index.mdx$ cat ~/blogs/engineering/claude-code-opus-haiku-cost/index.mdx # I put my name on this

Haiku output was 8.2x cheaper per token than Opus, not 40x

I wrote this. You can take notes.

"Opus plans, Haiku does the work at a fortieth of the price." That sentence is in the caption of a TikTok setup video posted on November 10, 2026, with 220,083 plays and 13,408 likes when I checked on November 26. The number in it is real. Anthropic's pricing page lists Opus 5.5 output at $20 per million tokens and Haiku 5.5 output at $0.50. That is exactly 40x.

I run Claude Code on three models, so I checked the 40x against my own transcripts. My Haiku output cost 8.2x less per token than Opus output. The gap shrinks because of a pricing rule the 40x leaves out, and a Claude Code habit that makes almost every request hit it.

What I measured

I ran a script over 118 Claude Code session files, 39 active days, in a snapshot taken on November 26, 2026 at 00:25 UTC. Project folders from my day job are excluded on purpose. One folder holds an automated content pipeline of mine that calls Claude Code headlessly. It contributes 59 of the 1,968 Haiku requests ($0.60), and they are included below. Without them, 98.80% of Haiku requests were over 100k tokens and the per-token output gap is 8.1x instead of 8.2x. The script reads the usage block that Claude Code writes on every assistant message and prices each request at list rates.

Two details come first.

First, a streamed reply writes several lines with the same message id, and in my transcripts each line repeated the usage so far. Summing every line counted 48,257 messages and $4,173.59. Merging repeated ids, taking the largest value per field, gives 28,778 messages and $2,387.35. Naive summing overstates the bill by 74.8%. All 13,296 repeated ids sit inside a single transcript file, so these are streaming chunks, not copied files.

Second, these are list-price equivalents: what the same tokens would cost on the API, not what I was billed. On a subscription you pay a plan price.

The 40x is the price for short prompts

The pricing page gives Haiku 5.5 two price rows. Its long context section says a request "whose prompt is over 100,000 tokens pays higher prices", that the count includes cache reads and cache writes, and that "Each request is priced on its own." Opus 5.5 and Sonnet 5.5 have one row across their full 1M context.

USD per million tokensOpus 5.5Haiku 5.5, prompt up to 100kHaiku 5.5, prompt over 100kHaiku realized, my dataOpus over Haiku realized
Input4.000.100.500.488.3x
Cache read0.200.010.050.0504.0x
Output20.000.502.502.438.2x

"Realized" is Haiku's list cost divided by its tokens, per token type, over all 1,968 Haiku requests. The 40x needs prompts at or under 100k tokens.

How long my prompts really were

Each request's prompt includes the conversation so far, and in my data most of it arrived as cache reads, so prompts grow as a session runs.

ModelRequestsMedian prompt (tokens)Prompts over 100kMean output per request
Opus 5.517,875352,56196.30%461
Sonnet 5.58,935187,58791.24%553
Haiku 5.51,968381,81198.07%1,087

My median Haiku request carried 381,811 tokens of prompt, nearly four times the threshold. Here is how the 1,968 Haiku requests fall around it:

Haiku prompt sizeRequests
Up to 100k (base price)38
100k to 150k113
150k to 200k179
Over 200k1,638

Only 38 requests, about 2%, billed at the rate the 40x assumes.

Reproducible cost table per model

These tables come from the ledger run described above. The script in the last section reproduces the Total column to four decimals. Tokens, after merging streamed lines:

ModelInputCache write 5mCache write 1hCache readOutput
Opus 5.543,026737,15353,490,3756,862,167,4658,234,558
Sonnet 5.521,806584,53419,787,5802,338,923,1694,939,471
Haiku 5.53,960191,4798,428,121826,094,4172,139,238

List cost in USD, by token type:

ModelInputCache write 5mCache write 1hCache readOutputTotalPer request
Opus 5.50.173.69427.921,372.43164.691,968.910.1101
Sonnet 5.50.041.4679.15233.8949.39363.940.0407
Haiku 5.50.000.058.0341.235.2054.500.0277

Opus carried 82.47% of the cost on 62.11% of the requests. Haiku wrote 13.97% of all output tokens and carried 2.28% of the cost. The per-request column compares different work, so its 4.0x gap describes my mix. The output row of the price table is the like-for-like comparison.

Across all models, the bill splits like this:

Token typeShare of list cost
Cache read69.01%
Cache write, 1-hour21.58%
Output9.19%
Cache write, 5-minute0.22%
Input0.01%

Within Opus alone, cache reads are 69.71% of its cost and output is 8.36%.

Why cache writes are a fifth of the bill

The 1-hour cache-write line came to $515.10.

A cache write stores context so later turns can read it cheaply. The pricing page charges 1.25x the input price for a 5-minute write and 2x for a 1-hour write, so a 1-hour write costs 1.6x a 5-minute one on all three models. It also says caching pays off "after one cache read" for 5-minute writes and "after two cache reads" for 1-hour writes. My transcripts read each cached token far more often than that: Opus read 126.5 cache tokens for every cache token it wrote, Sonnet 114.8 and Haiku 95.8.

Almost all of my writes were the expensive kind. 1-hour writes were 98.64% of Opus cache-write tokens, 97.13% for Sonnet and 97.78% for Haiku.

Claude Code's prompt caching docs explain where that comes from. Claude Code picks the cache lifetime per request. On a Claude subscription within the plan's included usage, it requests the 1-hour cache for the main conversation by default. With an API key, a cloud provider, or once usage credits kick in, the default is five minutes. You can override either bucket with the promptCacheTtl and subagentPromptCacheTtl settings, and FORCE_PROMPT_CACHING_5M=1 forces five minutes for both.

My user settings file and shell environment set none of these controls when I checked on November 26. A 98% share of 1-hour writes is what the documented subscription default would produce. The transcripts cannot show the billing mode, so this post does not say which applied.

What is the 1-hour choice worth in list price? Repricing my 1-hour write tokens at the 5-minute rate gives $321.94 instead of $515.10, a difference of $193.16, or 8.09% of total list cost. That is an upper bound: the pricing page says a 5-minute cache is valid for five minutes and charges a write each time content is stored, so longer pauses would add writes my transcripts cannot count. On a subscription the plan price covers it either way. On an API key, five minutes is already the default, so the comparison only matters if a one-hour TTL has been set.

Routing was not where my Haiku went

Routing advice assumes subagents carry the cheap-model work. In my data they did not. After merging streamed lines, 80 of 28,778 requests came from subagents: 47 on Opus, 28 on Sonnet and 5 on Haiku. Of my 1,968 Haiku requests, 1,963 ran in the main conversation. The subagent flag and the subagent folder agree exactly, so this is not a labelling gap.

My parallel workers are headless claude -p runs in their own git worktrees, as in my post on verifying worker claims, so their transcripts are not flagged as subagents. Subagents have their own limits, covered in my post on what the Claude Code binary hard-codes. If you route through subagents, your Haiku prompts may be shorter and closer to the base rate. Measure before you assume. My other Claude Code measurements are grouped on my AI coding agents page.

Here is the ceiling on the routing argument for my mix, price only:

ScenarioResult
All Opus output billed at Haiku's per-request output ratesaves 6.06% of total list cost
The same Opus token mix priced at Haiku's per-request rates$411.91, or 20.92% of the $1,968.91 Opus cost

Haiku's output quality was not measured, so these rows bound the savings and say nothing about whether the work would still pass.

What I changed

The first version of my script was wrong in two ways. Two more steps keep the numbers honest.

  1. It priced 1-hour cache writes at the 5-minute rate. That undercounted Opus by $160.47 and Sonnet by $29.68. The 1-hour line is now priced as listed: $8 per million tokens on Opus, $4 on Sonnet, and $0.20 on Haiku ($1 for Haiku requests over 100k).
  2. It ignored the Haiku long-prompt tier. The tier alone undercounted Haiku by $43.46 ($44.09 together with the first error), and it made my first estimate of the routing ceiling 4.24% of Opus cost. With the tier applied per request, the correct figure is 20.92%.
  3. Streamed lines are merged. Summing every line instead would add 19,479 lines and $1,786.24 of phantom cost.
  4. For this version, it freezes the window. A timestamp cutoff at the original run time means new sessions do not move the numbers. The cutoff run reproduces every per-model total exactly.

The number worth checking follows from the cache section: your share of 1-hour cache writes, before you look at model routing. On an API key the default is already five minutes, so a high 1-hour share there means a one-hour TTL is set somewhere: promptCacheTtl, CLAUDE_CODE_PROMPT_CACHE_TTL or ENABLE_PROMPT_CACHING_1H, possibly through managed settings. On my numbers the 1-hour lifetime was worth up to 8.09% of list cost, more than the output-only swap in the routing table.

Run it on your transcripts

This 29-line script prints messages, output tokens and list cost per model for any set of Claude Code transcripts. It merges streamed lines and applies Haiku's tier per request. Its fixture test passes, and on my full set it matches the ledger to four decimals.

#!/usr/bin/env python3
# Tokens and list-price cost per model from Claude Code transcripts. Repeated message ids are merged (max per field).
# Usage: python3 -I cost_by_model.py ~/.claude/projects/<dir>/*.jsonl   (USD/MTok in PRICE: verify before trusting)
import json, sys
from collections import defaultdict
PRICE = {"claude-opus-5-5": (4.0, 5.0, 8.0, 0.20, 20.0), "claude-sonnet-5-5": (2.0, 2.5, 4.0, 0.10, 10.0),
         "claude-haiku-5-5": (0.10, 0.125, 0.20, 0.01, 0.50)}
LONG = {"claude-haiku-5-5": (0.50, 0.625, 1.0, 0.05, 2.50)}  # Haiku 5.5 when the prompt is over 100k tokens
F, merged = ["in", "cw5", "cw1", "cr", "out"], {}
for path in sys.argv[1:]:
    for raw in open(path, encoding="utf-8", errors="replace"):
        try: m = json.loads(raw).get("message") or {}
        except ValueError: continue
        u = m.get("usage") if isinstance(m, dict) else None
        if not isinstance(u, dict): continue
        cc = u.get("cache_creation") or {}
        t = {"in": u.get("input_tokens", 0), "cw5": cc.get("ephemeral_5m_input_tokens", 0), "cw1": cc.get("ephemeral_1h_input_tokens", 0),
             "cr": u.get("cache_read_input_tokens", 0), "out": u.get("output_tokens", 0)}
        prev = merged.setdefault(m.get("id") or len(merged), (m.get("model", "?"), {f: 0 for f in F}))[1]
        for f in F: prev[f] = max(prev[f], t[f] or 0)
tot = defaultdict(lambda: {"msgs": 0, "out": 0, "cost": 0.0})
for model, t in merged.values():
    r, pk = tot[model], next((k for k in PRICE if model.startswith(k)), None)
    r["msgs"] += 1; r["out"] += t["out"]
    if pk:
        big = t["in"] + t["cw5"] + t["cw1"] + t["cr"] > 100000
        r["cost"] += sum(t[f] * x for f, x in zip(F, LONG[pk] if big and pk in LONG else PRICE[pk])) / 1e6
print("model\tmessages\toutput_tokens\tlist_cost_usd")
for model, r in sorted(tot.items()): print(f"{model}\t{r['msgs']}\t{r['out']}\t{r['cost']:.6f}")

Run it on every session file in your projects folder:

find "$HOME/.claude/projects" -name '*.jsonl' -print0 | xargs -0 python3 -I cost_by_model.py

If most of your Haiku requests carry prompts over 100k tokens, as long main-thread sessions do, compare Opus against the over-100k column of the price table, not the 40x.

Where others land

The dev.to post on Haiku subagents puts Haiku at 2.3% of cost, close to my 2.28%. Its cache reads were $135 of $354, about 38%, against my 69.01%. Its sample is one 24-hour window across five projects, and it gives two different shares of requests to Haiku, 95% and later 36.5%, so I would not use it as a baseline. Issue 52502 shows one reporter's /usage view with 14.8M cache-read tokens against 53.5k output tokens, closed as not planned. The reporter's numbers are not verified, but they point the same way as mine.

In my sessions, cache reads plus 1-hour cache writes came to 90.59% of list cost, so the 40x describes the output line, which was under a tenth of the bill.

$ ls ~/read/related

my other essays