I gave Claude's three model sizes the same nine coding tasks. The cheapest passed eight, and its one miss came with "Perfect!"
Choosing between Claude's small, medium and large models is mostly guesswork. I ran Haiku, Sonnet and Opus on nine small coding jobs with hidden tests and counted. Price and pass rate told a different story from what I'd assumed, and so did how each model reported its own work.
cheapest model passed 8 of 9 tasks at about 30% of the top model's cost
Level: Intermediate. About 20 minutes. Needs Node 20+ and a Claude Code login.
Claude Code lets you pick a model with --model: a small one (Haiku), a middle one (Sonnet) and a large one (Opus). The bigger ones cost more, and advice for choosing is mostly "it depends."
I wanted a number. For small, well-defined coding jobs, how much do you actually lose by picking the cheap one? So I wrote nine tasks, each with hidden tests, and ran all three models on all of them.
The tasks
Nine small jobs, each described in a plain paragraph, with a file for the model to edit and tests the model never saw:
Six were classic exercises. Three I made harder on purpose: an expression parser with precedence and error rules, a text wrapper with several fiddly rules, and a shopping-cart function with three bugs hidden in it, where the model has to find all of them from a description.
Before running anything I checked every test file against a solution I wrote by hand, and against the empty starting file. One of my own expected values turned out to be wrong, and I fixed it first.
Each model could edit the file and run node to try things. Then my tests scored the result. The models, as the command line resolved them: Haiku 4.5, Sonnet 5 and Opus 5. Note that Haiku here is an older generation than the other two, so the comparison mixes size and age.
The results
Sonnet and Opus passed all nine. Haiku passed eight. On the six easier tasks and two of the harder ones, the cheapest model was as good as the other two.
And the prices:
- Haiku: $0.60 for all nine.
- Sonnet: $1.62, about 2.7 times as much.
- Opus: $2.04, about 3.4 times as much.
That's what Claude Code reported for each run. I'm on a Pro plan, so I wasn't billed per run, but the figures show relative cost.
Time barely differed. Haiku took 306 seconds in total, Sonnet 255 and Opus 248. The cheap model wasn't the fastest, because on the hardest task it spent more turns.
The one miss
The only task Haiku failed in that first batch was the expression parser. I first took that for a steady weakness, because it failed three times in a row on a repeat. Then I kept running it, and the picture got messier.
Across 16 runs of the parser task in total, with my connected apps switched on and off and through two different scripts, Haiku was perfect 7 times and missed 9. Sonnet passed all 6 of its runs and Opus all 4.
The case it kept missing is 2^-1, a power with a negative exponent. My spec said unary minus was allowed, so that is valid, and Haiku's parser threw a syntax error. Once it also rejected the input 1 2.
Two things matter here. First, one pass proves little: if I'd stopped at the run where Haiku passed, I'd have written the opposite conclusion. Second, look at how Haiku reported the miss. Its last message said "Perfect! All test cases pass," followed by a list of what it handled. It hadn't tried that case, so its own tests couldn't fail. A confident summary is not evidence. The tests I'd written in advance were.
What I'd do with this
- Start with the cheap model for well-defined jobs. In these tests it handled eight of nine at roughly 30% of the top model's price.
- Move up when the spec has edge cases. The miss was in the most rule-heavy task, and there Haiku was a coin flip. Rules that interact, like precedence plus unary minus plus errors, are where the bigger models earned their price. (If you'd rather not choose by hand, a wrapper that tries the cheap model first and escalates when your own tests fail does the choosing for you.)
- Write the tests yourself, before you run anything. It was the only thing that caught the "Perfect!" claim. A model's own test suite covers what the model thought of.
- Don't read a cheerful summary as a pass. Run the tests.
- Measure on your own tasks. Nine small exercises tell you about nine small exercises.
What this doesn't tell you
- Nine tiny tasks, one run each, except the parser task, which I ran three times. A real project has bigger files, unclear requirements and many related files.
- The comparison mixes size and generation. Haiku 4.5 is older than Sonnet 5 and Opus 5, so I can't say how much of the gap is "small" and how much is "older."
- I judged only whether the hidden tests passed. I didn't compare code quality, readability or how the models explained their work.
- The prices are as Claude Code reported them. When I ran the same nine tasks again later through a different script, every model cost about 1.6 to 1.8 times more (Haiku $1.09, Sonnet $2.56, Opus $3.35 for the nine), though the ratios between models held. I suspect prompt caching, but I didn't verify it, so treat any single cost figure as rough.
- My tests are mine. A different set of edge cases could have caught Sonnet or Opus too.
Sources
- https://code.claude.com/docs/en/headless
Editorial note: We ran the steps in this guide ourselves and the screenshots come from those runs. Your results may differ with your plan, model or settings, so check anything important. Cover illustrations are AI-generated. Discovia is independent and not affiliated with Anthropic.
New guides and tools
Hands-on Claude guides, straight to your inbox
Step-by-step walkthroughs of what's new in Claude and Anthropic's tools, with real screenshots and honest results, including what didn't work. No hype, no jargon, no noise.
By subscribing, you agree to receive newsletter and marketing emails, and accept our Terms of Use and Privacy Policy. You can unsubscribe anytime.
Claude Code Lab
Tests of Claude Code features: hooks, skills, rules files and workflows, with the numbers.
More Claude Code guides →


