Sample Preview
Sample
Codex CLI Cost

Cutting Codex CLI Cost: A Field Manual for Engineering Teams

A complete operating model for spending fewer credits in OpenAI's terminal coding agent: the model menu, reasoning effort, profiles, caching, context, instructions, tools, and the governance that makes the savings stick.

Where the credits go

Codex CLI is OpenAI's coding agent that runs in your terminal. It reads your files, runs commands, and writes code, and every one of those actions moves text to and from a large language model. You pay for that text in credits (on a ChatGPT plan) or in token dollars (on the direct API). The size and shape of that text, not the cleverness of any one prompt, is what sets your bill.

The cost lives in a handful of places: the model you pick and how hard you tell it to think, the standing background that gets re-sent on every turn (your rules, tool descriptions, and conversation so far), the files and command output you feed it, and the answers it writes back. This report walks each of those levers in order of impact, teaches every term the first time it appears, and ends each part with the specific thing to do. The techniques apply at any size; where a lever matters more for a small, medium, or large team, that is called out.

The three ideas that drive everything else

It compoundsThe model re-reads the whole conversation on every reply. A session does not cost once; it costs again, larger, on each turn. Lean sessions win.
Repeats are cheapBackground text that is byte-for-byte identical to last time is billed at roughly one-tenth the normal input rate. Keep it stable and most of your input is nearly free.
Routing beats trimmingSending routine work to a cheap, low-effort model saves more than any amount of prompt wordsmithing on an expensive one.
The headline result. A realistic mixed workload, modeled across a busy team, drops from about 83 credits to 37 credits per session once these controls are in place: roughly 55% fewer. The two largest contributors are tool-output reduction and cached-input discipline; model routing and effort tuning come close behind. Your numbers will differ. The direction does not.
One accounting rule first. Codex CLI has two separate money systems: credits for ChatGPT-plan usage, and token dollars for direct API usage. They are different commercial regimes. Never add savings from one to budgets in the other without a conversion bridge, or your arithmetic will be wrong. Keep them on separate budget lines from day one.

Invoice platform baseline

An engineering team builds an invoice ingestion and reconciliation platform with upload API, parser, reconciliation engine, ledger database, admin UI, audit log, ERP connector, tests, and deployment.

Costly default

Codex runs at the highest model and high reasoning effort for every task. Long sessions mix API work, parser failures, ledger migrations, UI changes, and connector review.

Optimized workflow

Profiles route triage, implementation, migration, and research differently. Stable prefixes, scoped context, local preprocessing, compact tools, and accepted-change telemetry govern the build.

Savings note: The reference workload drops from about 83 credits to 37 credits per mixed session once these controls compound See Appendix A.1.

1. The three token buckets and the repeat discount

Models read and write text in small chunks called tokens (roughly three-quarters of a word each). Codex bills tokens in three buckets, and the price gap between them is where a large share of your savings lives.

You never count tokens by hand. You only need the rule of thumb: more text means more tokens means more cost, and not all tokens cost the same. Here are the three buckets, with illustrative GPT-5.5-class rates used for planning. Treat the exact numbers as placeholders to refresh against the live pricing page; the ratios are the durable part.

BucketWhat it isIllustrative rateRelative cost
InputEverything sent to the model: your request, files it reads, command output, your standing rules, tool descriptions.~125 credits / 1M tokensBaseline (1x)
Cached inputBackground text that is byte-for-byte identical to a recent request. Billed at the discounted rate automatically.~12.5 credits / 1M tokensAbout 0.1x
OutputEverything the model writes back, plus hidden reasoning where it is billed. The most expensive bucket.~750 credits / 1M tokensAbout 6x

Three facts fall out of that table. First, output is roughly six times the price of fresh input, so a chatty assistant is expensive in two ways: the answer itself, and the fact that the answer becomes part of the history that gets re-read on every later turn. Second, cached input is roughly ten times cheaper than fresh input, so anything you can keep identical from turn to turn is nearly free to repeat. Third, because the model has no memory between turns, your standing background gets re-sent on every reply, which is exactly why the cached discount matters so much.

Like a metered call where talking back costs the most

You are not billed a flat fee for "a session." You are billed by how much text moves, like a call billed by the minute. A short, focused exchange is cheap. A rambling one where the other side reads you a long document and you repeat yourself is expensive. Talking back (output) is the priciest part of the call, and repeating yourself is discounted, but only if you repeat the exact same words.

Where this points the rest of the report

Every later section is an application of these three facts. Routing and effort control the expensive output bucket. Caching, context, and AGENTS.md control how much input repeats and whether it qualifies for the discount. Tool and verbosity controls keep both input and output from ballooning. If you internalize the buckets, the rest is just tactics.

Do this: When a session feels heavy, ask one question: "How much text is moving here, and how much of it repeats unchanged?" That question points directly at every fix in this report.

Invoice upload API and repeat discount

The upload API needs endpoint handlers, validation, error types, tests, and OpenAPI notes across several turns.

Costly default

Developers edit AGENTS.md, switch models, paste different requirement versions, and add tools mid-session.

Optimized workflow

They lock model, effort, and tool surface first, keep stable rules at the top, and place only volatile evidence at the end.

Savings note: More of the standing prefix qualifies for cached input and fewer repeated tokens are paid at fresh-input rates See Appendix A.2.

2. Model tiering: the menu and how to route Highest leverage

After tool-output reduction and cache discipline, choosing the right model for each task is the single largest cost lever you control. Codex CLI exposes several model backends at very different prices, and the default temptation is to run the most capable one for everything.

A capable, expensive reasoning model and a fast, cheap one read the same files and write the same kind of answer; they differ in how deeply they reason and in price per token. As a planning reference, a mid-tier model is priced near half of the top model per token, and a lightweight "mini" model is cheaper still. The difference looks small per call and enormous per month, because it multiplies across every session.

The model menu

Confirm current names and prices against the live pricing page before you rely on them; model names change often. The shape of the menu is stable even when the labels move.

TierExampleBest forRelative price
Top reasoningGPT-5.5 classArchitecture, security migrations, unclear root cause, incident responseHighest
Mid reasoningGPT-5.4 classBounded code repair, test fixing, refactors with clear scope~50% of top
LightweightGPT-5.4-mini classFormatting, renames, boilerplate, file operations, simple lookupsCheapest hosted
Local / openOSS model via --ossLow-stakes, human-reviewed routine work on your own hardwareNo API cost

You set the model in three ways: as the org-wide default in ~/.codex/config.toml, per session with the -m / --model flag, or mid-session with the /model command to escalate when a cheap route is struggling. The goal is to make the cheap model the default and treat the expensive one as a deliberate escalation, not the other way around.

# ~/.codex/config.toml -- make the cheap model the default
model = "gpt-5.4-mini"
model_reasoning_effort = "low"

# Escalate for one session from the command line
codex -m gpt-5.5 --config model_reasoning_effort=high

# Or mid-session in the TUI, only when the cheap route stalls
/model gpt-5.5

Cloud carries a premium over local

Submitting a task to Codex Cloud (the hosted, autonomous execution service) costs materially more than running the same task in the local CLI, on the order of several times more for the container startup, isolation, and unattended-run safeguards. As an illustration, a job that costs a handful of credits locally can cost several times that in cloud. Default to local CLI for interactive development; reserve cloud for long unattended jobs, CI and pull-request integration, or work that genuinely needs cloud isolation, and scope those jobs tightly so they stop the moment the work is done.

A concrete routing policy

Good intentions do not scale; a written policy does. Map each class of work to a model, an effort level, an answer length, and a tool surface, then publish it. This table is the reference you adapt to your own task mix.

Task classModelEffortVerbosityTools
Formatting, rename, boilerplatemini or midlowlownone or file-read
Test triage, log analysismidlow / mediumlowissue-read, file-range-read
Bounded code repairmidmediumlow / mediumfile-read, run-tests
Architecture, designtophighmediumscoped repo tools
Security migrationtophighmedium / highscoped, no web
Incident responsetophighmediumpriority route, budget override
Research, docs refreshmid or topmediummediumweb search, domain-scoped
Report writingtopmediumhighnone (output is the artifact)

The aim is for the cheap model to handle 60 to 80 percent of sessions. When it does, mixed workloads commonly drop 30 to 50 percent in credit cost from routing alone.

Escalate without paying twice

When a cheap route fails, the expensive model does not start from scratch and re-read everything at full price. Hand it a compact escalation packet: which route failed, a short summary of what was tried, a pointer to the evidence already gathered, and the specific open question. That preserves the work and keeps the premium model's input small. If a route escalates often, the route is misconfigured, not the developer; fix the routing rule.

Route on quality-adjusted cost, not raw tokens

The metric that prevents false savings is not token count. It is the cost of an accepted change: credits plus review time plus any retry credits, divided by the number of changes that actually shipped. A cheap route that produces rework can cost more than a premium route that gets it right the first time. Measure accepted-change cost per route and promote a workflow to a richer route when its cheap-route version costs more in the end.

Do this: Set the cheap model and low effort as the default in config.toml. Publish a one-page routing card. Keep interactive work local. Escalate to the expensive model deliberately, with a compact handoff, and judge routes by accepted-change cost. Medium / large teams: highest impact

Reconciliation engine model routing

The reconciliation engine needs invariant design, boilerplate status handlers, fixture generation, and final review.

Costly default

The top model handles architecture, boilerplate, formatting, test scaffolding, and field renames.

Optimized workflow

The top model designs matching invariants and reviews final logic; cheaper routes handle routine implementation, tests, and formatting.

Savings note: Premium calls fall to the few steps that need deep reasoning See Appendix A.3.