API pricing vs subscription: what my month of Codex would cost on the API

By

Tagged: AI

I priced 30 days of my real Codex usage at API rates. A $100 plan covered $745 of API-equivalent work. Here's the math, the script to run on your own logs, and when the API still wins.

I pay $100 a month for ChatGPT Pro, and most of what I do with it happens in Codex. Codex keeps a log of every session on disk, including the tokens each model call used.

So I added up the last 30 days and priced every call at the public API rates. The answer: $745.16. Without prompt caching, the same work would have cost $8,234.34.

That’s the whole comparison for a heavy user. The rest of this post shows where those numbers come from, the script to run the same check on your own logs, and the cases where paying per token is still the better deal.

Two ways to pay for the same model

A subscription charges a fixed monthly price and gives you an allowance that resets on a schedule. The API charges for every token you send and receive, with no allowance at all.

Subscription (ChatGPT, Claude, Cursor)API key
What you payA fixed monthly pricePer million input, cached and output tokens
What limits you5-hour and weekly usage windowsRate limits, and your spend
Long promptsNo long-context surcharge in Codex2x input and 1.5x output above 272K tokens on GPT-6.1 Sol
Bad monthYou hit the limit and wait, or buy creditsYou get a bigger bill
Good forWorking in the agent every dayLight or bursty use, CI, features in your own app

The prices as of today:

PlanPrice per monthCoding agent
ChatGPT Plus$20Codex, with 5-hour and weekly limits
ChatGPT Pro$100, $200 or $500Codex, no 5-hour limit, weekly limit only
Claude Pro$20 ($17 billed yearly)Claude Code
Claude Max$100Claude Code, 5x Pro usage
Claude Ultra$200Claude Code, 10x Pro usage, no 5-hour limit
Cursor Premium$30Cursor, third-party models billed at API list price
Cursor Ultra$200Cursor, 50x the usage of Plus

From Italy the ChatGPT page shows €23 for Plus and €103 for Pro, because European prices include VAT.

My last 30 days in Codex

Codex writes one JSONL file per session in ~/.codex/sessions, organized by date. Older sessions get compressed to .jsonl.zst. Every model call adds a token_count event with the running totals for the session:

{"input_tokens":169105,"cached_input_tokens":56448,"output_tokens":227,"reasoning_output_tokens":19,"total_tokens":169332}

The input_tokens count includes the cached tokens, and output_tokens includes the reasoning tokens. Those are the same numbers OpenAI bills on.

I ran the script from the end of this post over the last 30 days:

┌─────────┬───────────────┬───────┬───────────┬──────────┬────────────┬────────────┬────────────┐
│ (index) │ model         │ calls │ input (M) │ cached % │ output (M) │ API cost $ │ no cache $ │
├─────────┼───────────────┼───────┼───────────┼──────────┼────────────┼────────────┼────────────┤
│ 0       │ 'gpt-6.1-sol' │ 9751  │ 1904.9    │ 98.3     │ 3.89       │ 402.74     │ 5569.95    │
│ 1       │ 'gpt-6-astra' │ 1620  │ 229.3     │ 98.2     │ 0.67       │ 314.18     │ 2434.96    │
│ 2       │ 'gpt-6-sol'   │ 85    │ 6.4       │ 97       │ 0.05       │ 2.08       │ 13.17      │
│ 3       │ 'gpt-5.6-sol' │ 443   │ 53.5      │ 98.6     │ 0.11       │ 26.16      │ 216.26     │
└─────────┴───────────────┴───────┴───────────┴──────────┴────────────┴────────────┴────────────┘
Last 30 days at API rates: $745.16 (without caching: $8234.34)
Not priced: codex-auto-review

That’s 11,899 model calls across 25 active days, about 475 a day. On average each call cost $0.063 at API rates.

codex-auto-review is the model Codex uses to judge a risky action, like a shell command, before running it. It made another 8,434 calls, and since it isn’t sold on the API I left it out. Priced like GPT-6.1 Sol, it would add about $198.

Two numbers in that table surprised me.

The first is the input size. The median call sent 150,460 input tokens to GPT-6.1 Sol, and 10% of calls sent more than 337,000. I type one line, and the agent sends the system prompt, the tools, the files it read and the whole conversation so far. Every call re-sends all of it.

The second is how little of that I paid full price for. 98% of the input was cached.

Caching decides the bill

A cached token is part of a prompt the provider has seen recently, like the start of a conversation that grows one turn at a time. OpenAI charges 5% of the normal input price for it:

GPT-6.1 Sol pricing on the OpenAI API: $2.00 input, $0.10 cached input, $2.50 cache writes, $10.00 output per million tokens

Here is where the $402.74 for GPT-6.1 Sol came from:

Part of the billTokensRate per millionCost
Cached input1,872M$0.10, or $0.20 above 272K$271.96
Uncached input32.6M$2.00, or $4.00 above 272K$84.78
Output, reasoning included3.89M$10.00, or $15.00 above 272K$46.00
Total$402.74

Output, the part most people think about, was the smallest line. On a coding agent, the bill is input re-sent over and over, and caching is the only reason it’s affordable at all. Without it my month goes from $745 to $8,234.

This is also why most “how much would I pay on the API” estimates are wrong. If you multiply all input tokens by the input price, you overestimate by 11x, like my $8,234. If you count only what you type, you miss almost everything, because a one-line request still sends around 150,000 tokens.

Notice the “above 272K” rates too. 2,024 of my GPT-6.1 Sol calls went over 272K input tokens, and on the API those cost 2x for input and 1.5x for output. That surcharge is $111.41 of the $402.74. The model page says that usage drawn from a subscription has no long-context surcharge, so on the plan those calls cost me nothing extra.

The same month at other API prices

The same token counts priced on other models give an idea of the range. This assumes every request stays in the cheaper short-context tier, and on the Claude models it counts uncached input as cache writes, which cost 1.25x input.

ModelInputCached inputOutputMy 30 days
Claude Haiku 5.5 (prompts over 100K)$0.50$0.05$2.50$143
GPT-6.1 Sol$2$0.10$10$338
Claude Sonnet 5.5$2$0.10$10$357
Claude Opus 5.5$4$0.20$20$714
Claude Fable 5.2$8$0.20$40$997

It’s a price list comparison, not a prediction. A different model makes a different number of calls for the same task, and Anthropic’s default cache lasts 5 minutes, so the cached share can be lower if you step away between turns.

Even at Haiku prices, my month costs more than a $100 plan.

What the subscription gives you instead: limits

The plan didn’t make my usage free. It made it capped. Codex records the rate limit state on every call, so I could check that too.

On Pro there’s no 5-hour window, only a weekly one. In those 30 days the weekly bar went past 95% six times. When it’s full, Codex stops until the reset, or until you buy extra credits. On the API that same week would have been a bigger invoice instead.

The usage is also very uneven. A median day cost $6.81 at API rates, while the busiest day, November 4, cost $195.45. The next four days together cost 31 cents. A subscription averages that out. On the API, the busy days hit the bill exactly as they happen.

So the choice for heavy use isn’t about price, because the plan wins by a lot. It’s about whether you can live with the weekly limit, or whether your work needs to keep going when you hit it.

When the API is cheaper

At my average of $0.063 per call, $20 buys about 320 calls on the API and $100 buys about 1,600. I make 1,600 calls in less than four active days.

You come out ahead on the API when:

  • You use an agent a few times a week, for short sessions. 300 calls a month is a light user.
  • Your use comes in bursts with long quiet periods, and a plan would charge you for the quiet weeks.
  • The calls happen inside a product you ship. Then it’s not your usage, it’s your users’, and it goes through the API anyway. I wrote about that case in how to safely add paid AI features to a desktop app.
  • You run jobs in CI or scripts that shouldn’t eat the allowance you need for interactive work.

If you want to skip both and run a model on your own hardware, that’s a different comparison, with a GPU and electricity instead of an invoice. I did that math in running LLMs locally vs paying for an API, and there’s how to use a coding agent without another subscription too.

Using both

You don’t have to pick one. The plans now come with API credits:

SubscriptionMonthly API credits
ChatGPT Pro $100$100
ChatGPT Pro $200$200
ChatGPT Pro $500$500
ChatGPT Business Standard$20 per seat
ChatGPT Business Premium$100 per seat
Claude Max$100
Claude Ultra$200
Claude Teamup to $500, pooled

ChatGPT credits need a paid Pro or Business plan that’s at least seven days old, with the ChatGPT account and the API organization on the same email. Business credits are pooled, with a $500 a month cap per workspace. Unused credits expire at the end of the billing cycle. The details are in the ChatGPT API credits guide.

Be careful with one limit: the ChatGPT credits don’t cover Codex used with an API key, and they don’t raise your Codex limits. They’re for the API Platform, like the Responses and Agents APIs, which is the “feature in my own app” or “script in CI” case from the previous section.

So the subscription covers the hours you spend talking to the agent. The included credits cover a side project or a script. If you run past the weekly limit on a day you can’t wait, Codex works with a regular API key too, billed at API rates.

Cursor works differently. On the new plans, Premium at $30 and up includes a usage pool for Cursor’s own and Grok models, and third-party models like GPT and Claude are billed separately at API list price. That’s a subscription for the editor with an API bill on top.

The full list of what I pay for, Cursor included, is in my one-person business costs.

Choosing between a coding subscription and the APIMeasure real usage from your logs, price it at API rates, compare it with the plan price, then check whether the plan's limits fit how you work.NoYesYesNoPrice 30 days ofreal usage at APIratesAPI cost above theplan price?Pay per token withan API keyCan you live withthe plan's weeklylimit?SubscriptionBigger plan, orsubscription plus anAPI key for overflow

Price your own month

Here’s the script I used. It reads every Codex session file, works out the tokens each call added, and prices them at the GPT-6.1 Sol, GPT-6 Astra, GPT-6 Sol and GPT-5.6 Sol rates, with the long-context tier above 272K. It needs Node 22.15 or later, for zstdDecompressSync. Save it as codex-api-cost.mjs:

import { readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { homedir } from 'node:os'
import { zstdDecompressSync } from 'node:zlib'

// $ per million tokens: [input, cached input, output], short then long context
const rates = {
  'gpt-6.1-sol': [[2, 0.1, 10], [4, 0.2, 15]],
  'gpt-6-astra': [[10, 1, 50], [20, 2, 75]],
  'gpt-6-sol': [[2, 0.2, 10], [4, 0.4, 15]],
  'gpt-5.6-sol': [[4, 0.4, 20], [8, 0.8, 30]],
}
const longContext = 272_000
const days = Number(process.argv[2] ?? 30)
const since = new Date(Date.now() - days * 86_400_000).toISOString()

function files(dir) {
  return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
    const path = join(dir, entry.name)
    if (entry.isDirectory()) return files(path)
    return /\.jsonl(\.zst)?$/.test(entry.name) ? [path] : []
  })
}

const totals = {}
const skipped = new Set()

for (const file of files(join(homedir(), '.codex', 'sessions'))) {
  const raw = readFileSync(file)
  const text = file.endsWith('.zst') ? zstdDecompressSync(raw).toString() : raw.toString()
  let model
  let previous

  for (const line of text.split('\n')) {
    if (!line.includes('"turn_context"') && !line.includes('"token_count"')) continue
    const event = JSON.parse(line)
    if (event.type === 'turn_context') {
      model = event.payload.model
      continue
    }
    const usage = event.payload.info?.total_token_usage
    if (!usage) continue
    if (previous && usage.total_tokens < previous.total_tokens) previous = undefined
    const input = usage.input_tokens - (previous?.input_tokens ?? 0)
    const cached = usage.cached_input_tokens - (previous?.cached_input_tokens ?? 0)
    const output = usage.output_tokens - (previous?.output_tokens ?? 0)
    previous = usage
    if (event.timestamp < since || (input <= 0 && output <= 0)) continue
    if (!rates[model]) {
      skipped.add(model)
      continue
    }

    const [inputRate, cachedRate, outputRate] = rates[model][input > longContext ? 1 : 0]
    const t = (totals[model] ??= { calls: 0, input: 0, cached: 0, output: 0, cost: 0, noCache: 0 })
    t.calls++
    t.input += input
    t.cached += cached
    t.output += output
    t.cost += ((input - cached) * inputRate + cached * cachedRate + output * outputRate) / 1e6
    t.noCache += (input * inputRate + output * outputRate) / 1e6
  }
}

const rows = Object.entries(totals).map(([model, t]) => ({
  model,
  calls: t.calls,
  'input (M)': +(t.input / 1e6).toFixed(1),
  'cached %': +((t.cached / t.input) * 100).toFixed(1),
  'output (M)': +(t.output / 1e6).toFixed(2),
  'API cost $': +t.cost.toFixed(2),
  'no cache $': +t.noCache.toFixed(2),
}))
console.table(rows)
const sum = (key) => rows.reduce((a, r) => a + r[key], 0).toFixed(2)
console.log(`Last ${days} days at API rates: $${sum('API cost $')} (without caching: $${sum('no cache $')})`)
if (skipped.size) console.log(`Not priced: ${[...skipped].join(', ')}`)

Run it with the number of days you want to look at:

node codex-api-cost.mjs 30

On my 700 session files it takes about 4 seconds. If a model shows up under “Not priced”, add its rates from the OpenAI pricing page to the rates object.

Compare the total with what you pay for the plan. If it’s below, an API key is cheaper for you. If it’s well above, like mine, the subscription is the better deal, and the question becomes whether its limits fit the way you work.

Estimate your own usage

If you use Claude Code or the ChatGPT app and want to compare plans from estimates before pulling logs, plug in your daily usage and cached share below:

AI subscription vs API calculatorInteractive · runs in your browser

Your subscription

Your usage (all editable)

Start from:

Each user + assistant turn counts as one message.

Everything sent on each call: system prompt, tools, files and the conversation so far. A coding agent often sends 100K+ tokens for a one-line request.

Input the provider has seen recently is billed at the cache-read rate, 5% of the input price on GPT-6.1 Sol and Claude Sonnet 5.5. In a long coding session it's usually above 95%.

messages/day · messages/mo · input tokens · output tokens

vs equivalent API

API equivalent

/mo

Subscription

/mo

Break-even: — messages/day where API cost equals the subscription price (holding token sizes and active days fixed).

Every subscription at your usage

API-equivalent monthly cost using each plan's default model. Click a row to select it. Plan prices verified November 10, 2026, API rates November 10, 2026.

PlanAPI modelSub $/moAPI $/moVerdict

Caveats

  • A plan gives you an allowance, not unlimited use. Heavy use hits the 5-hour or weekly limit, and the API would bill that usage instead. This tool compares token-equivalent spend only.
  • API prices are the standard tier. Batch and Flex are half price, Fast mode costs more, and Claude cache writes (1.25x input) are billed here as plain input.
  • Codex and Claude Code let you pick the model. Change the API model above to match the one you use most.
  • All figures are estimates for planning — not billing quotes.

Want me to talk about your product? You can sponsor this site.

Related posts about ai: