qvib.pro
RU

~10 min read · Updated: 28 Jul 2026

Claude Code vs Codex CLI: Where Your Tokens Go

Claude Code vs Codex CLI: Where Your Tokens Go

In short

Claude Code and Codex CLI are both terminal coding agents, and both are cheapest through a subscription rather than a raw API key. Claude Code runs on a Claude plan — Pro at $20/month, Max from $100/month as of July 2026. Codex CLI signs in with a ChatGPT plan (Plus, Pro, Business, Edu, Enterprise) or, with extra setup, an API key. The claim you see repeated in comparison posts — that one tool burns several times more tokens than the other on the same task — is weaker evidence than it looks, because the two vendors do not count tokens the same way. Anthropic's own pricing docs note that Claude 4.7 and later use a newer tokenizer producing roughly 30% more tokens for the same text. So compare dollars, not token counts, and compare them on your repo. On both tools the dominant cost driver is not the model choice. It is how many turns the agent takes, how often it re-reads the same files, and whether your prompt prefix stays stable enough to hit cache.

Two different bets on how an agent should work

Both tools do the same job: sit in your terminal, read the repo, edit files, run commands, iterate until tests pass. The difference is what they assume about the loop around that.

Claude Code bets on a long, continuous session. It keeps one conversation alive, compacts it when the context window fills, and expects project rules in a CLAUDE.md that gets re-read into every session. The mental model is a colleague who stays in the room all afternoon.

Codex CLI bets on a bounded, sandboxed run. Its open-source repo is Apache-2.0, it installs via npm install -g @openai/codex or Homebrew, and its default posture is to sign in with your ChatGPT plan rather than hand it an API key. Project instructions live in AGENTS.md — the same convention several other agents now read, which is why an AGENTS.md file is worth writing once and reusing.

Neither bet is wrong. They just fail differently, and they fail at different prices.

Token counts are not a currency

Most "X uses 4x the tokens of Y" comparisons take the token counter from each tool's status line and divide. That number is not comparable across vendors for three separate reasons.

First, tokenizers differ. Anthropic states plainly in its pricing documentation that Claude 4.7 and later models use a newer tokenizer that "produces approximately 30% more tokens for the same text" than earlier Claude models. If the tokenizer boundary moved 30% within one vendor's own lineup, cross-vendor token counts are measuring encoding as much as effort.

Second, price per token differs by model and direction. Claude Opus 5 is $5 in / $25 out per million tokens; Claude Sonnet 5 runs $2 / $10 through August 31, 2026, then $3 / $15; Haiku 4.5 is $1 / $5. GPT-5.3-Codex lists at $1.75 in / $14 out per million on OpenRouter's model page. A tool that "uses more tokens" on a cheaper model can still cost less.

Third, and most important for agents: cached input is priced at a fraction of fresh input. On the Claude API a cache hit costs 0.1x the base input rate, while a 5-minute cache write costs 1.25x. An agent replays the whole conversation on every turn, so input tokens dwarf output tokens, and your cache hit rate — not your model — decides the bill.

What you are comparing Why it misleads What to compare instead
Total tokens per task Different tokenizers, different encoding of the same text Dollars billed, from each vendor's own usage view
Input tokens Cache hits cost ~10% of fresh input on the Claude API Cached vs uncached input, reported separately
Model price per million Output is 5x input on most models here Blended cost per completed task
Benchmark scores Run on someone else's repo, at someone else's context size Turns-to-green on your repo, over ~10 real tasks
Subscription price Both start near $20/month; limits are windowed Hours per week you spend rate-limited

Token cost on the same task: how to actually measure it

You can settle this for your codebase in an afternoon. The setup matters more than the tooling.

Pick five tasks you have already done, so you know what "correct" looks like: one bug fix with a failing test, one multi-file refactor, one new endpoint, one dependency upgrade, one "why is this slow" investigation. Run each on a clean branch in both tools, from the same starting prompt, with the same project instructions available.

Then record four things per run: dollars billed (from the vendor's own usage view, not a third-party token counter), number of turns, number of times the agent re-read a file it had already read, and whether you had to intervene. That last column decides the money. An agent that gets there in six turns at a higher per-token rate beats one that takes twenty turns cheaply, and both lose to the run where you rewrote the result yourself.

Two habits move the number more than switching vendors: keeping the early part of the conversation stable so the cache prefix survives, and not letting the agent explore the repo blind. If you find yourself paying for the same src/ tour every session, that is a project-instructions problem, not a pricing problem — the fixes are the same ones in our notes on cutting Claude Code token use.

Where each one wins

Honest version: the gap between these two is smaller than the gap between a good session and a sloppy one with either.

Claude Code is the better fit when the work is long and stateful — a refactor that touches thirty files, a migration where the plan matters more than any single edit, a debugging session where you want the agent to keep a hypothesis in mind across an hour. Compaction and subagents exist because the sessions are expected to be long. The cost of that design is that a bad early instruction poisons an expensive context, and you pay to carry it.

Codex CLI is the better fit when the work is bounded and you want the blast radius controlled — a scoped change in a repo you do not fully trust yourself in, a run you want sandboxed by default, a task you are happy to hand off and check. Because it is bundled into ChatGPT plans, teams already paying for ChatGPT often have it without a new line item.

The caveats cut both ways: published head-to-head benchmark numbers change with every model release and are almost never reproducible on your repo; subscription limits are windowed, so overuse shows up as waiting rather than a bigger invoice; and the subscription path on both sides has usage terms and limits that differ from the API path you would use in CI.

Routing work between them

Running both is cheaper than it sounds, because the $20 tier on each side covers a surprising amount of solo work, and the two rate-limit windows are independent. The practical split most people land on:

  • Planning and architecture in whichever tool you trust more to say "this design is wrong" — then hand the plan, not the conversation, to the other.
  • Implementation in one tool, review in the other. A second model reading a diff cold catches things the author model rationalized.
  • Long investigations in Claude Code, bounded and sandboxed edits in Codex CLI.
  • Anything cheap and mechanical — renames, test scaffolding, changelog writing — on the smallest model either vendor offers, not the flagship. The same logic that drives model routing inside Claude applies across vendors.

Do not run both on the same working tree at the same time. Two agents editing concurrently produces merge conflicts nobody wrote and neither can explain.

What neither of them fixes

Both tools charge you for your own context hygiene. A repo with no instructions file, no test command the agent can find, and a 400-line function nobody has read in a year is expensive in either tool, and the bill looks like a model problem.

Neither one reviews itself honestly. Both will report success on a task where the tests never ran. The sandbox in Codex limits damage; it does not judge correctness.

And neither is a substitute for a spec. The largest cost item in agentic coding is the task you described badly, discovered three turns in, and restarted. That is not billed as an error — it is billed as tokens.

FAQ

Is Codex CLI cheaper than Claude Code?

At the subscription level they start in the same place: a Claude Pro plan is $20/month and Codex is included with paid ChatGPT plans starting at the same tier (as of July 2026 — check claude.com/pricing and OpenAI's current plan page before budgeting). At the API level the per-token rates differ, but the deciding factor for most people is turns-to-correct on their own code, not the rate card.

Do Claude Code and Codex CLI use the same number of tokens for the same task?

No, and the difference is not a clean signal. The vendors use different tokenizers, so identical text encodes to different counts — Anthropic documents a roughly 30% increase for the same text on Claude 4.7 and later versus earlier Claude models. Compare billed dollars instead.

Can I use both without paying twice?

You can, but both at full speed means two subscriptions. The cheaper path is one paid plan plus an API key on the other side, used only for review passes — API usage is billed per token with no monthly floor, so a few review runs cost cents.

Does prompt caching actually reduce my bill in an agent session?

Yes, and materially, because agents resend the whole conversation each turn. On the Claude API a cache hit is billed at 0.1x the base input rate while a 5-minute cache write is 1.25x, so the cache pays for itself after a single read. The catch is that editing early context invalidates the prefix — which is why long stable sessions are cheaper per turn than sessions you keep rewriting from the top.

Which one should a solo developer pick if they can only pick one?

Take the one whose failure mode you can live with. Long sessions on a codebase you know favor Claude Code's stateful design. Bounded, sandboxed runs — and an existing ChatGPT plan — favor Codex CLI. Run the five-task test above before committing to a year of either.

Read next