What common Claude Code tasks cost, measured on each model
AutoRouter11 min read
AutoRouter, the Mac app for Codex and Claude Code, ran five everyday Claude Code tasks three times each on Claude Opus 5.5, Claude Sonnet 5.5 and Claude Haiku 5.5 on October 28, 2026: a commit message, a rename across files, tests for one module, a failing-test fix and a multi-file refactor. At Anthropic's list prices that day, an average run cost $0.110 on Opus 5.5, $0.049 on Sonnet 5.5 and $0.0044 on Haiku 5.5, and all 45 runs passed their automatic checks. The runs used a Claude Max subscription, so they cost nothing beyond the plan. With an API key, Claude Code uses a shorter prompt cache that is cheaper to write, and the same runs would have cost about a fifth to a quarter less: $0.084, $0.037 and $0.0035. AutoRouter wrote this post, and the study measured Claude Code alone, with no router in between.


How was the cost measured?
Each run started Claude Code 2.1.305 in print mode (claude -p) on a fresh copy of the same Python repository and recorded the tokens and the list-price cost that Claude Code reports when it finishes. The repository is pallets/itsdangerous at commit 672971d (June 14, 2025): 1,176 lines of source and 297 tests. Every run had its own copy and virtual environment, and one task, model and attempt per session.
- Model: chosen with
--model, signed in with Claude Max and no API key set. - Settings: project settings only (
--setting-sources project) and--strict-mcp-config, so no personal CLAUDE.md, hooks, plugins or MCP servers loaded (CLI reference). Permissions were skipped inside the copy. - Cost: the
total_cost_usdfield of Claude Code's JSON result, with the per-model token counts beside it. On a subscription no money changes hands, so this is Claude Code's list-price estimate for the tokens. - Checks: each task's check was confirmed to fail on an untouched copy and pass on a correct solution before the first counted run.
The method was written on October 27, 2026, before any run. It and all 45 observations, one dated line per run, are published: method and results.
| Task | Prompt, in short | Passes when |
|---|---|---|
| Commit message | Commit a staged one-method change | Exactly one commit added, nothing left staged, subject 1 to 72 characters |
| Rename across files | Rename want_bytes to to_bytes everywhere (27 uses in 6 files) | No want_bytes left, def to_bytes exists, all tests pass |
| Tests for one module | Write pytest tests for encoding.py, whose test file was deleted | The tests pass and cover at least 90% of encoding.py |
| Fix a failing test | Find a planted bug that fails 5 tests, without changing the tests | All tests pass and no test file changed |
| Multi-file refactor | Move three base64 helpers into a new module and update every import, keeping the old import working | Helpers live only in the new module, no import uses the old path, the old import still works, all tests pass |
What does each Claude Code task cost on each model?
An average run cost $0.110 on Claude Opus 5.5, $0.049 on Claude Sonnet 5.5 and $0.0044 on Claude Haiku 5.5 at list prices on October 28, 2026, so Opus 5.5 cost 2.2 times Sonnet 5.5 and 25 times Haiku 5.5 per task. Each cell is the mean of three runs, and the costs reconcile exactly with the token counts times the published rates for Opus 5.5, Sonnet 5.5 and Haiku 5.5.


| Task | Claude Opus 5.5 | Claude Sonnet 5.5 | Claude Haiku 5.5 |
|---|---|---|---|
| Commit message | $0.082 | $0.034 | $0.0024 |
| Rename across files | $0.097 | $0.038 | $0.0037 |
| Tests for one module | $0.125 | $0.062 | $0.0055 |
| Fix a failing test | $0.078 | $0.040 | $0.0032 |
| Multi-file refactor | $0.168 | $0.070 | $0.0072 |
| Average run | $0.110 | $0.049 | $0.0044 |
| Average run with an API key | $0.084 | $0.037 | $0.0035 |
| All 15 runs | $1.647 | $0.733 | $0.066 |
The multi-file refactor was the most expensive task on every model, and the failing-test fix and the commit message the cheapest. Three runs of the same task on the same model never differed by more than about 1.5 times in cost. With an API key, 1,000 runs of tasks like these would cost about $84 on Opus 5.5, $37 on Sonnet 5.5 and $3.50 on Haiku 5.5 at these averages.
Why is Haiku 5.5 only 25 times cheaper when its prices are 40 times lower?
Claude Haiku 5.5 did each task in more steps, so it used more tokens at its lower price. As of October 28, 2026, Haiku 5.5's output and cache-write rates are a fortieth of Opus 5.5's and its cache reads a twentieth (pricing), for prompts up to 100,000 tokens. Across its 15 runs, Haiku 5.5 took 1.5 times as many turns as Opus 5.5, wrote 1.7 times as much output and read 1.6 times as much from the cache. On the refactor it averaged 8.7 turns against 4.3 on Opus 5.5 and Sonnet 5.5.


The extra turns didn't make it slower on these tasks. Average wall time stayed within 9 seconds across the three models on every task: the refactor took 33 seconds on Opus 5.5, 24 on Sonnet 5.5 and 30 on Haiku 5.5.
Did the cheaper models pass as often?
Yes: all 45 runs passed, five tasks times three models times three runs. That shows these five tasks were within reach of all three models in a small, well-tested repository. It doesn't show the models are equal on harder work. On Terminal-Bench 4.0, Anthropic reported 39.2% for Claude Haiku 5.5 against 70.6% for Claude Sonnet 5.5 in its October 7, 2026 launch post.
Every model wrote tests that covered all of encoding.py; Opus 5.5 wrote 26 to 40 tests per run and Haiku 5.5 wrote 45 to 52. One check changed after the runs: the refactor check first counted a code comment that mentioned the old import path as a failure. Ignoring comment lines and rescoring all nine saved refactor runs turned one Haiku 5.5 run from a fail into a pass and changed nothing else.
Where does the money go in a Claude Code task?
Writing to the prompt cache was the largest cost on every model: 63% on Opus 5.5, 66% on Sonnet 5.5 and 51% on Haiku 5.5. Claude Code caches the prompt so each later request reads the unchanged start of the conversation at a discount, and in these runs nearly every input token went through the cache: no run sent more than 18 uncached input tokens. On a Claude subscription, Claude Code requests the one-hour cache for the main conversation, and every run's cost matches that rate: twice the input price, or $8 per million tokens on Opus 5.5, $4 on Sonnet 5.5 and $0.20 on Haiku 5.5 as of October 28, 2026 (pricing).


| Model, 15 runs | Cache writes | Output | Cache reads | Total |
|---|---|---|---|---|
| Claude Opus 5.5 | $1.034 (63%) | $0.435 (26%) | $0.178 (11%) | $1.647 |
| Claude Sonnet 5.5 | $0.481 (66%) | $0.170 (23%) | $0.082 (11%) | $0.733 |
| Claude Haiku 5.5 | $0.033 (51%) | $0.018 (28%) | $0.014 (21%) | $0.066 |
A fresh session writes Claude Code's system prompt, its tool definitions and the files it reads into the cache, between 6,500 and 16,300 tokens per run here. That is a fixed setup cost per session. On Opus 5.5 it was about 69% of a commit message's $0.082. Starting a fresh Opus 5.5 session for every small job pays that setup each time; the same setup on Haiku 5.5 costs a fortieth as much.
Does an API key change what the same task costs?
Yes: with an API key, these runs would have cost 24% less on Opus 5.5, 25% less on Sonnet 5.5 and 19% less on Haiku 5.5. With an API key, usage credits or a cloud provider, Claude Code uses the five-minute cache, whose writes cost 1.25 times the input price (pricing). No run here lasted more than 40 seconds, so a five-minute cache would have stayed warm throughout. Cache writes would still be the largest cost: 51% on Opus 5.5, 54% on Sonnet 5.5 and 39% on Haiku 5.5. The one-hour cache pays off in sessions you leave idle and come back to, and the promptCacheTtl setting chooses either one.
What does this mean on a Claude Pro or Max plan?
On a plan, these runs cost nothing beyond the subscription and count against its usage limits instead. Anthropic doesn't publish those limits in tokens; its pricing page says how much you can do depends on the length and complexity of your conversations and the model you choose. This study didn't measure how much of the Max limit the 45 runs used. Claude Code's default model on Pro, Max and the Anthropic API is Opus 5.5 as of October 2026, so small jobs run on the most expensive of the three unless you change it.
Subscription or API: which is cheaper for coding agents? works through where a plan beats paying per token. For every lever that lowers the bill, from the model to the context each request carries, see How to cut Claude Code and Codex costs.
How do you run small tasks on a cheaper model?
Pass a model for the one job, and leave your main session on the model you debug with. Each model keeps its own prompt cache, so a separate command avoids re-reading a long conversation after a /model switch:
claude -p --model haiku "Commit the staged changes"
How to send quick coding tasks to a cheaper model covers subagents and the same setup in Codex. Doing it by hand means sorting every task yourself.
AutoRouter, the Mac app for Codex and Claude Code, works out how hard each turn is and sends quick tasks to the cheapest capable model, which is often your ChatGPT or Claude plan or a low-cost open model. A model has to clear the quality bar for the task before price counts, hard work goes to the strongest model your plans cover, and every turn shows its model, what it cost and why. Routing across your plans is free; Pro is $20 a month and adds every other model at the provider's price plus 10%. AutoRouter earns that 10% on paid models and nothing on your plans. It is in beta, works with Codex and the Claude Code CLI on macOS 14 or later, and sometimes misjudges how hard a task is; you can rate the pick or choose a model yourself.
What can't this study tell you?
It measures five small, well-specified tasks in one small Python library, and its numbers will move with your codebase and habits:
- Bigger repositories cost more. A task that reads more files writes and reads more cache.
- Long sessions shift the mix. Each run here was a fresh session, so setup dominated. In a long interactive session, re-reading the growing conversation from the cache takes a larger share; Anthropic's cost guide lists ways to keep it short.
- Three runs per cell show spread. They don't give a statistically tight average.
- List prices only. Batch, fast mode and US-only inference price differently.
- One Claude Code version. Version 2.1.305's system prompt and tools set the setup cost; other versions will differ.
- Cost, measured on Claude Code alone. It isn't a quality benchmark and doesn't measure AutoRouter.
Questions
How much does a commit message cost in Claude Code?
In this study, a commit message cost $0.082 on Claude Opus 5.5, $0.034 on Claude Sonnet 5.5 and $0.0024 on Claude Haiku 5.5 at list prices on October 28, 2026, as Claude Code priced a subscription session; with an API key it would be about $0.061, $0.025 and $0.0018. Each was a fresh claude -p session on a one-method change, and all nine runs produced a valid commit. On a Pro or Max plan, the same run uses plan limits instead of money.
Does the same task cost the same every time?
No. Three runs of the same task on the same model differed by up to about 1.5 times in cost, because the model took a different number of turns or wrote more. The Opus 5.5 commit message ranged from $0.072 to $0.100.
Why is the prompt cache the biggest cost?
Because Claude Code sends almost all of its input through the cache, and writing to it costs more than plain input: twice the input price for the one-hour cache a subscription session uses, and 1.25 times for the five-minute cache an API key uses. Each fresh session writes the system prompt, tool definitions and the files it reads, then later requests read them back at a small fraction of the input price.
How can I see what my own tasks cost?
Run the task with claude -p --output-format json, whose result includes total_cost_usd and the token counts per model, or check the Session block of /usage in an interactive session. On a Pro or Max plan, both figures are list-price estimates; Anthropic notes the session cost isn't relevant for billing there, because usage is included in the plan. Anthropic's cost guide covers the other tools for tracking usage.
Sources
- Pricing, Claude Platform docs, Anthropic
- What's new in Claude Opus 5.5, Claude Platform docs, Anthropic
- Plans and pricing, Anthropic
- Introducing Claude Haiku 5.5, Anthropic
- How Claude Code uses prompt caching, Claude Code docs
- Manage costs effectively, Claude Code docs
- Model configuration, Claude Code docs
- CLI reference, Claude Code docs
- pallets/itsdangerous, GitHub