Claude vs GPT for Coding: Same List Price, Different Bill
Why Claude Sonnet 5.5 and GPT-6.1 Sol produce very different coding bills at the same list price: cache writes, prefix invalidation, 272K context cliffs, reasoning tokens.

Summary
- Identical per-million token list prices rarely produce identical coding bills because coding agents re-send massive context windows across dozens of internal.
- Prompt cache invalidation—triggered by pruned screenshots, session resume bugs, or expired TTLs—turns cheap 0.1x cache reads into 1.25x–2.5x cache writes.
- GPT-6 and GPT-6.1 Sol double input rates past 272K tokens, while Claude's tokenizer counts roughly 30% to 50% more tokens on the same source code.
- Setting reasoning effort to medium instead of max and compacting context before the 272K cliff are the fastest ways to cut both API bills and subscription.
When you put Claude Sonnet 5.5 and GPT-6.1 Sol side by side on a pricing page, their base per-million token rates look nearly identical. If you run both models on the same repository for a week, however, the invoices—or your 5-hour and weekly subscription meters—rarely match.
In a coding harness like Claude Code or Codex CLI, you are almost never paying the headline uncached input rate for a single prompt and response. A single prompt you type on screen routinely triggers 20 to 50 internal tool calls, file reads, grep searches, and test runs. Because the agent re-sends your conversation history on every single step, your real bill is governed by five mechanics that don't show up in a simple input/output price comparison:
- Cache write multipliers and silent prefix invalidation
- How many internal continuations the harness fires per turn
- Long-context surcharge cliffs (specifically OpenAI's 272K threshold)
- Reasoning tokens billed at full output rates
- Tokenizer density differences on raw source code
Here is how those five factors split the bill between Claude and GPT in real coding workflows, and how I configure both to stop runaway token burn.
On this page
Side-by-Side: Where the Billing Mechanics Split
Even when two models start at the same base rate (for example, $5 per 1M input tokens and $25–$30 per 1M output tokens as of 2026-10-29), the surrounding billing rules diverge quickly once a coding session grows past a few files.
| Billing Factor | Claude (Sonnet 5.5 / Opus 5.5) | GPT (GPT-6.1 Sol / GPT-5.6 Sol / Astra) | Impact on Your Coding Bill |
|---|---|---|---|
| Cache Read Rate | 0.1x of base input (API) / ~0.025x weight (Subscription) | 0.1x of base input | Keeps multi-step tool loops affordable—only while the prefix stays intact. |
| Cache Write Rate | 1.25x (5-min TTL) / 2.0x (1-hour TTL on API) | 1.25x (30-min TTL) / 2.5x (12-hour TTL) | Since GPT-5.6, OpenAI also bills 1.25x for cache writes. Any cache miss penalizes you above list price. |
| Long-Context Cliff | Flat rate up to standard window limits | 2x input / 1.5x output past 272K tokens | Codex sessions with a 500K window silently cross 272K and double in cost per turn. |
| Reasoning Effort | low, medium, high, max (billed as output) |
low, medium, high, xhigh (billed as output) |
max / xhigh can increase per-task cost by 5x–10x without changing the listed token rate. |
| Tokenizer Density | ~30% to 50% more tokens on identical code/text | Baseline token count | Claude bills more raw tokens for the exact same file tree before generation even starts. |
1. Cache Writes and Silent Prefix Invalidation
Prompt caching is the only reason agentic coding is financially viable. If your session holds 400,000 tokens of repository context and the agent takes 30 steps to fix a bug, reading that prefix from cache at 0.1x costs a fraction of re-sending it at full price.
The trap is that prompt caching requires an exact prefix match from the beginning of the conversation. If anything alters an earlier message in the array, the cache breaks at that exact token. On the very next tool call, you don't just lose the 90% read discount—you pay the 1.25x to 2.5x cache-write surcharge to rebuild the entire suffix.
I see three specific prefix-invalidation bugs cause massive bill spikes in Claude Code and OpenAI-compatible harnesses:
Automatic Image and Media Pruning
If you paste UI screenshots or game assets into a long coding session, the client eventually hits its media request limit and strips older images out of the conversation history, replacing them with a placeholder string like [media removed: request limit].
Because that replacement modifies an early message in the history (messagesHistoryChanged / prefix_mismatch), the entire cached context after that image is invalidated. In a single eight-minute window on an 840K-token session, I have seen cache reads collapse from 849,000 tokens down to 35,906 while cache_creation.ephemeral_1h_input_tokens logged 2,325,403 cache-write tokens across just three responses (763,932, 767,624, and 793,847). On a subscription plan, that single eight-minute spike wiped out 30% of a weekly Max 20x allowance.
Session Resume and Subagent Serialization Bugs
When you run claude -p --resume or wake a subagent via SendMessage, the client has to reconstruct the message array identically to the previous turn. In Claude Code versions prior to v2.1.261, starting a fresh session sent messages[1] as a content-block array with cache_control attached, but --resume serialized that same message as a plain string.
The result: cache_read_input_tokens froze at around 8K–22K (covering only the static system prompt and tool definitions), while the entire growing conversation history was billed as a fresh cache_creation write on every single turn. Updating Claude Code to v2.1.261 or later fixes the --resume serialization, though subagents woken mid-task can still trigger partial prefix rewrites.
TTL Expiration and Relay Account Switching
Claude's default ephemeral cache lasts 5 minutes (at 1.25x write cost) or 1 hour (at 2.0x write cost on the API). GPT's cache tiers sit at 30 minutes (1.25x) and 12 hours (2.5x). If you pause for ten minutes to read documentation and your 5-minute TTL expires, your next "continue" prompt re-writes the entire 300K context at 1.25x.
The same thing happens immediately if you use a third-party API relay that load-balances requests across a pool of upstream accounts. When request #4 hits a different upstream organization than request #3, the upstream cache misses 100% of the time. If you use a gateway, make sure you know how to check that an LLM API relay really serves the model you pay for and keeps sticky sessions per conversation. If you are thinking about a Gemini model on a gateway, see using Gemini 4 Carbon via OpenRouter.
2. Harness Loop Multiplication: 8 Visible Turns = 266 API Calls
When developers compare Claude Code against Codex CLI, they often judge usage by how many prompts they typed. The billing meter only cares about how many backend responses the harness generated.
In Codex CLI (for example, running gpt-5.6-sol or gpt-6.1-sol at medium effort with an 872K context window), just 8 user-visible turns across two debugging sessions can generate 266 internal model responses. Because the agent carries its retained context across every internal continuation and shell command check, those 8 prompts processed 96.15 million total tokens—roughly 94.96 million of which were cached input tokens.
Even when 98% of your input hits the cache at a 90% discount, multiplying a 400K–800K context window by 266 internal turns burns through roughly $50 to $100 of API value in under two hours.
3. The 272K Long-Context Cliff on GPT-6 and Sol
One of the sharpest differences between Anthropic and OpenAI billing right now is how they price long context windows:
- OpenAI (GPT-6 Astra, GPT-6.1 Sol, Terra): Once your input context crosses 272,000 tokens, OpenAI applies a long-context surcharge that bills 2x on input tokens and 1.5x on output tokens (see the full breakdown in our OpenAI API Pricing (2026): GPT-6 Astra, Sol, Luna guide).
- The Client Window Mismatch: Many Codex CLI configurations default to a
500,000token context window (with a 95% auto-compaction threshold at475,000tokens). That leaves a wide band between 272K and 475K where the client does not compact your history, yet every single tool call is billed at double the input rate and 1.5x the output rate.
If you don't manually lower your compaction threshold below 272K on GPT models, the second half of every long coding session costs twice as much per turn as the first half.
4. Reasoning Effort (medium vs max) Is an Output Multiplier
Both providers charge the exact same per-token rate regardless of your reasoning effort setting. Whether you run effort: medium or effort: max (or xhigh on GPT-6), the price table doesn't change.
Your bill changes dramatically because every hidden reasoning token is billed at the output token rate, which is 5x to 6x higher than the input rate.
When you set GPT-6 Astra or Claude Opus 5.5 to max / xhigh for routine coding, the model frequently spends 15,000 to 40,000 thinking tokens analyzing edge cases before editing ten lines of code. Across real repository benchmarks and daily debugging:
- Running Claude Opus 5.5 or Sonnet 5.5 at
mediumor GPT-6.1 Sol atmediumdelivers the same or higher pass rates on standard software engineering tasks because the model doesn't over-complicate straightforward fixes. - Dropping from
maxon Astra tomediumon Sol or Opus/Sonnet cuts the average cost per resolved issue by 80% to 90%.
Unless I am asking the model to untangle a race condition or design a cross-module architecture from scratch, I keep reasoning effort locked at medium.
5. Tokenizer Density and Subscription Quota Math
Two final differences explain why identical workloads still diverge even when caching, context length, and thinking effort are controlled:
Claude's Tokenizer Uses ~30% to 50% More Tokens on Code
A million tokens is not a standardized unit of code. If you feed the exact same source files, JSON payloads, and mixed English/CJK comments into both tokenizers, Claude's tokenizer consistently produces 30% to 50% more tokens than GPT's tokenizer. A repository slice that measures 100,000 tokens in Codex will frequently register as 140,000 to 150,000 tokens in Claude Code. Even when the per-million token price is identical on paper, Claude charges you for more tokens on the exact same text.
How Subscription Quotas Weight Your Tokens
If you use a $200/month subscription (Claude Max 20x or ChatGPT Pro, as of 2026-10-29) instead of raw API keys, your usage bar is driven by an internal credit weight formula rather than raw token counts.
On Claude subscriptions, the quota consumption closely follows a weighted formula where uncached input is 1x, cache writes (both 5-minute and 1-hour) are 1.25x, cache reads are 0.025x, and output tokens are 5x:
$$\text{Quota Burn} = I + 1.25W + 0.025R + 5O$$
Because cache reads are weighted at 0.025x (not zero), carrying a 1M-token context window burns your 5-hour quota noticeably faster than a 200K window. More importantly, because a cache write is weighted 50 times heavier than a cache read (1.25 vs 0.025), a single 200K-token cache miss eats more than 20% of a standard 5-hour Pro quota immediately.
On the OpenAI side, switching models inside a Pro subscription also changes your effective allowance. While GPT-6.1 Sol gives you roughly $1,900 to $2,000 of equivalent API value per full weekly quota bar as of 2026-10-29, switching to GPT-6 Astra burns the weekly bar roughly 2x to 5x faster per token—yielding closer to $1,000–$1,230 of API-equivalent usage before hitting the weekly cap. For newer models, see the latest model and API changes.
How to Keep Your Coding Bill Predictable
Whether you are paying per token on the API or rationing a 5-hour subscription window, four adjustments eliminate almost all surprise billing spikes:
- Cap GPT compaction below 272K: In Codex or your custom agent harness, set your effective context compaction limit to 250,000 tokens when calling GPT-6.1 Sol or GPT-6 Astra so you never trigger the 2x long-context surcharge.
- Use 1-hour cache TTLs and idle compaction on Claude: On Claude subscriptions, 5-minute and 1-hour cache writes carry the same
1.25xweight. Enabling the 1-hour TTL with automatic idle compaction at 400K–500K tokens prevents a 10-minute coffee break from turning your next prompt into a full-context cache miss. - Start a fresh session after heavy image debugging: Do not keep coding for hours in a thread where you pasted a dozen screenshots. Once the client starts pruning old media placeholders, your cache prefix will break on every turn. Compact or start a clean session as soon as the visual fix is done.
- Check your gateway's cache parameter support: Some OpenAI-compatible proxies strip cache headers or double-count cached tokens as uncached input when translating between Anthropic Messages and OpenAI Chat Completions formats. If your gateway throws parameter errors when configuring cache lifetimes, see our guide to fixing
prompt_cache_retention is not supported on this modelgateway 400 errors.