OpenCode vs Claude Code: Same Sonnet 5.5 Fix, Fewer Tokens in OpenCode
Same model, same bug, nearly the same code. The bill differed by a third, and most of the gap is Claude Code's prompt size and cache lifetime.
OpenCode is free, open source and runs whatever model you point it at. Claude Code comes with a paid Claude plan. So put the same model behind both. Does the tool around it change the fix, or only the bill?
We gave both the same two-part billing bug with Claude Sonnet 5.5, three runs each. Every run in both tools passed all 8 hidden tests, and five of the six made the same code change. OpenCode's fixes cost $0.078 on average. Claude Code's cost $0.116 at API list price, and the gap comes from its much larger prompt and the cache it writes on a subscription.
One difference showed up outside the code. With the same allow list, Claude Code ran its own tests in every run and OpenCode in none.
And if you pay for a Claude plan, OpenCode can't use it, which settles the choice for you.
How we tested: On October 15, 2026 we had OpenCode 2.0.29 and Claude Code 2.1.300 fix the same billing bug with Claude Sonnet 5.5 at high effort, three runs each, judged by 8 hidden tests neither agent saw. OpenCode ran through OpenRouter and Claude Code on a Claude subscription, and the token counts, costs and screenshots below are our own.
The results side by side
| OpenCode + Sonnet 5.5 | Claude Code + Sonnet 5.5 | |
|---|---|---|
| Hidden tests passed | 8 of 8, in 3 of 3 runs | 8 of 8, in 3 of 3 runs |
| Tests the agent added | 5, 4, 5 | 5, 6, 6 |
| Cost per fix | $0.066 to $0.086 (mean $0.078) | $0.106 to $0.127 (mean $0.116) |
| Same tokens at the 5-minute cache rate | $0.078 | about $0.096 |
| First request to the model | 3,700 tokens | 18,903 tokens |
| Cached tokens read per fix | 30,776 to 61,775 | 145,675 to 172,361 |
| Output and thinking tokens per fix | 4,014 to 5,186 | 4,098 to 5,487 |
| Model requests per fix | 5 to 7 | 7 to 8 |
| Ran its own tests | 0 of 3 runs (blocked, and said so) | 3 of 3 runs |
| How the model was paid | Per token, through OpenRouter | Claude subscription |
All costs are at Anthropic's list price for Sonnet 5.5: $2 per million input tokens and $10 per million output (Anthropic pricing, checked October 16, 2026). OpenCode's figure is what OpenRouter billed us. Claude Code's is its own list-price figure for usage that came out of the subscription. The Claude Code runs are the Sonnet runs from our Claude 5.5 cost test, the same task on the same day.
Did the tool change the fix?
No. All six runs fixed both parts of the bug: an event on the first day of a period billed in two periods, and periods cut on UTC dates instead of the customer's time zone. Here are the hidden tests passing on run 1 from each tool.

Then we diffed the fixes. Five of the six runs made the same three code changes: a tz parameter on events_in_period, each timestamp converted to that zone before taking its date, and <= end changed to < end. Between OpenCode's run 1 and Claude Code's run 1, the billing code differs only in a docstring.

OpenCode's second run took another route (it compared full timestamps against local midnight) and passed all 8 as well. Claude Code's runs wrote a few more tests of their own (17 in total against 14). OpenCode's new tests passed too when we ran them afterwards, although OpenCode never ran them itself (more on that below).
Same model, same answer. That holds for one small repository with one bug. On a large codebase, where the tool's search and context handling do more of the work, the two could split, and this test doesn't show that.
Why did OpenCode cost less with the same model?
Two reasons, and each explains about half of the 3.8-cent gap per fix.
Claude Code sends a much bigger prompt. Its first request in each run was 18,903 tokens. OpenCode's was 3,700. Both held the same two support tickets, so the difference is each tool's system prompt and tool definitions. Every later request carries that prompt again, so over a run Claude Code read 145,675 to 172,361 cached tokens against OpenCode's 30,776 to 61,775. Cache reads are cheap on Sonnet 5.5 ($0.10 per million), so the reads cost Claude Code 1.5 to 1.7 cents per fix and OpenCode 0.3 to 0.6. OpenCode's runs also did a little less work, because none of them ran its tests. A short tool call at their final prompt size cost about a third of a cent (run 3's sixth request: 14,044 tokens, 70 output tokens, 0.36 cents), so a test run or two wouldn't close the gap.
Our Claude Code had five plugins installed, so we checked whether they inflated the prompt. A probe the next day with the same settings (Claude Code 2.1.301, one patch newer) listed 28 tools and 19 skills, only one of them from a plugin. Turning all skills off made the prompt bigger, not smaller (18,682 tokens with them, 22,009 without). The bulk is Claude Code's own prompt and tools.
Claude Code writes a pricier cache on a subscription. Each request stores the new part of the prompt in Anthropic's cache. By default, Claude Code asks for the one-hour cache on a Claude subscription, within the plan's included usage. With an API key it defaults to the five-minute one (Claude Code caching docs, checked October 16, 2026). Anthropic charges $4 per million tokens for one-hour cache writes and $2.50 for five-minute writes. Claude Code wrote 12,457 to 13,826 tokens per run at the one-hour rate, 43 to 47% of its list-price cost. OpenCode wrote 9,291 to 11,219 at the five-minute rate.
The split, per fix on average:
- One-hour rate: 13,090 tokens written × the $1.50 per million difference = about 2.0 cents
- Bigger prompt: about 1.1 cents more in cache reads and 0.7 cents more in cache writes
- Output: 4,800 tokens against 4,729, under 0.1 cents apart
So what would Claude Code cost with an API key? We didn't run that. Pricing its own token counts at the five-minute rate gives $0.087 to $0.107 per fix (mean $0.096), still 23% more than OpenCode's $0.078. That assumes the same cache hits, which a real API-key run might not get.
On a subscription, none of this reaches your card. It counts as plan usage.
Can you use your Claude plan in OpenCode?
No. OpenCode's own docs say plugins exist that let you use Claude Pro or Max in OpenCode, that "Anthropic explicitly prohibits this", and that OpenCode stopped bundling them in version 1.3.0 (OpenCode providers docs, checked October 16, 2026). Anthropic's Claude Code legal page says subscription sign-in is "designed to support ordinary use of Claude Code and other native Anthropic applications", and that third-party developers may not "offer Claude.ai login into their own applications" (Claude Code legal docs, checked October 16, 2026).
Outside a Claude plan, you can run Claude models in OpenCode per token, with an Anthropic API key or through a router like OpenRouter, which is what we did. (We've compared OpenRouter alternatives separately.) A GitHub Copilot plan also works in OpenCode, and Copilot lists Claude Sonnet 5.5 among its models (GitHub Copilot supported models, checked October 16, 2026). We didn't test that route. Claude Pro, which includes Claude Code, is $20 a month or $17 a month billed yearly (Claude pricing, checked October 16, 2026).
There's one twist for Max subscribers. Max 5x now includes $100 a month of API credits and Max 20x $200. Anthropic's docs list the Claude API as covered and Claude Code as not covered (API credits for Max and Team plans, checked October 16, 2026). An API key from the linked Console organization is exactly what OpenCode takes. So on paper, a Max subscriber can run OpenCode on Claude from those credits, about 1,280 fixes like ours for $100 ($100 / $0.078). We haven't tested that.
Is either one faster?
We can't rank them from these runs. OpenCode's fixes took 35 to 48 seconds each from start to finish, one run at a time. Each Claude Code run shared the machine with two other Claude Code sessions (Haiku and Opus runs of the same test) and took 148 to 157 seconds, of which 30 to 38 seconds was time spent waiting on the model. Those aren't the same measure. Both needed under a minute of model time for a bug this size.
Did both stay inside the rules?
Yes, but the same rules played out differently. We allowed reading, editing inside the project and six shell commands (python3, ls, cat, grep, find and diff). Claude Code also runs a built-in set of read-only commands such as head and tail without asking, in every mode (Claude Code permissions docs, checked October 16, 2026). OpenCode applied our list as written.
So every OpenCode run tried to run its tests piped into tail, was blocked, and finished without running them. Each one said so in its final message (run 1: "I couldn't run the test suite, because the shell command was denied"). Claude Code piped its test runs into tail too, and they went through. It had one command blocked per run: a sed -i edit in runs 2 and 3, which it redid with its Edit tool, and in run 1 a check that copied a file to /tmp, which it dropped.
No run wrote outside its own copy of the repository. If you lock OpenCode's shell down, allow the read-only commands your agent pipes output into, or it may stop without testing its own fix.
What tripped us up in OpenCode
Claude Code needed nothing beyond the login it already had. OpenCode 2 took more care, mostly because we drove it from scripts:
npm install opencode-aigave us version 1.19.0 on October 15, and on October 16 npm's latest was 1.19.2, still a 1.x release. Version 2.0.29 came fromopencode upgrade --major --method curl.- OpenCode 2 starts a background service that its terminal, web and desktop apps all connect to (OpenCode 2.0 notes, checked October 16, 2026). We stopped it and ran every test with
--standalone. opencode runwaited for input on stdin and hung. Closing stdin (< /dev/null) fixed it.- It takes its project from the
PWDvariable it inherits, not from the directory the process starts in. A pilot run opened a different repository on our machine. It only searched and read files, changed nothing and cost $0.095. Our test script now setsPWDfor every run. - It titled each session with a small OpenAI model, GPT-6 Luna, billed to the same OpenRouter key (under one cent in total). The
small_modelsetting picks that model (OpenCode config docs, checked October 16, 2026).
None of these matter much if you type opencode in a terminal and work. They matter in CI or a script.
Does the model matter more than the tool?
In this test, by far. We also ran Gemini 4 Argon in OpenCode on the same bug. It passed all 8 hidden tests in all three runs too, but cost $0.20 to $0.25 per fix (mean $0.223) and took 190 to 274 seconds, mostly because it spent 9,160 to 15,848 thinking tokens against Sonnet's roughly 700. That's nearly three times Sonnet's cost in the same tool, a much bigger gap than the one between the tools. The full numbers are in Gemini 4 Argon vs Claude Sonnet 5.5.
Which one should you run?
- You pay for Claude Pro or Max: Claude Code. The plan covers it, and OpenCode would bill you per token on top.
- You pay per token anyway (an API key, OpenRouter, a company budget): OpenCode. With the same model it wrote the same fix from fewer tokens, and Claude Code's tokens priced 23% higher even at the five-minute cache rate. Allow the read-only commands it needs, so it tests its own work.
- You want models from more than one vendor: OpenCode. It takes Gemini, OpenAI models and many more, and its docs say ChatGPT Plus and GitHub Copilot subscriptions work in it (OpenCode providers docs, checked October 16, 2026). We only tested it through OpenRouter.
- You're on Max with API credits you don't use: OpenCode on those credits looks worth a try, but we haven't tested it.
A large refactor or a long session could change the picture, and the other Claude Code alternatives we've covered weren't part of it. If you've switched in either direction, tell us why on X at @devtoolpicks.
Frequently Asked Questions
Does OpenCode have something like Claude Code's auto mode?
Not the same kind. In Claude Code's auto mode a second model, a classifier, reviews actions instead of you. OpenCode's --auto flag approves every permission request that no deny rule blocks, and its docs describe no reviewing model. Out of the box most OpenCode permissions are already set to allow, so --auto on the defaults approves nearly everything. The safety has to come from your rules. Deny by default, then allow what the agent needs. That is how we ran every OpenCode test, with --auto on top.
Can OpenCode be as cheap as Claude Code on a Claude Pro plan?
We can't give a break-even, because Anthropic publishes no fixed usage count for Pro. In our test, one small bug fix on Sonnet 5.5 in OpenCode cost 0.078 USD through OpenRouter. So 20 USD a month, Pro's price, buys about 256 fixes that size at per-token prices. A cheaper model stretches that further. Haiku 5.5 fixed the same bug for 0.016 USD on average in our Claude Code test, but we didn't run it in OpenCode.
Get honest tool comparisons in your inbox
Join 50+ indie hackers and solo developers who get new comparisons, pricing changes, and tool picks. No spam. Unsubscribe anytime.
Related Articles
Best AI Coding Agent Security Tools for Indie Hackers in 2026
A Cursor agent deleted a production database in 9 seconds. Here is what actually...
Running AI Coding Assistants Locally: Is It Worth It in 2026?
Local coding models now handle most daily prompts on a laptop. Here is the hones...
Anthropic Academy: Which Free AI Courses Are Worth Taking for Indie Hackers in 2026?
Anthropic quietly launched a free learning platform in March 2026 with 17 course...