Back to guides
Comparison·July 26, 2026·8 min read

Claude Code vs Codex CLI — what actually differs, and how to choose

Claude Code and Codex CLI do the same job from the same place. The durable differences are model family, extension surface and how freely you can point each at your own endpoint — that last one is sharper than most comparisons admit.

Claude Code and Codex CLI solve the same problem from the same place: an agent in your terminal that reads the repository, proposes edits, runs commands and iterates on the result. They differ in the model family behind them, the extension surface, and how you configure them — not in the basic shape of the work.

This page compares what actually differs, gives a decision rule rather than a verdict, and shows how to run both from one key if you want to judge them on your own code.

Side by side

Claude CodeCodex CLI
FromAnthropicOpenAI
Model familyClaude (Opus, Sonnet, Haiku)GPT / Codex
API surfaceAnthropic MessagesOpenAI-compatible
ConfigEnv vars + ~/.claude/settings.json~/.codex/config.toml
Custom endpointANTHROPIC_BASE_URLmodel_providers block
Extension surfaceMCP, subagents, hooks, skills, plan modeLeaner; open-source Rust binary
Execution sandboxingPermission prompts and hooksLocal sandbox policies
Editor integrationVS Code and JetBrains extensionsTerminal-first

Both are actively developed and both move quickly, so treat any feature list — including this one — as a snapshot. The structural differences (model family, API surface, config format) are the stable part; specific features are not.

How to choose

There is no general answer to which produces better code — it varies by language, repository and task, and published head-to-head benchmarks rarely resemble your codebase. What you can decide up front is which one fits how you work:

If you want…Lean toward
MCP servers, subagents, hooks, skillsClaude Code
Plan-then-execute on large changesClaude Code
Team-wide config in a committed settings fileClaude Code
An open-source binary you can auditCodex CLI
Stricter local execution sandboxingCodex CLI
To stay inside one vendor's model familyWhichever matches it

The honest recommendation: both are free to install, so put the same real task from your own repository through each and compare the diffs. An afternoon of that tells you more than any comparison article, including this one.

What each costs to run

Cost is a property of the model and the number of agentic steps, not of the CLI. Both tools resend the system prompt, the task history and fresh file context on every step, so the per-token rate compounds identically in each. Compare the models you would actually run:

ModelRuns inKunavo in / out per 1M
claude-sonnet-4-6Claude Code$1.20 / $6.00
claude-opus-5Claude Code$2.00 / $10.00
claude-haiku-4-5Claude Code (background)$0.40 / $2.00
gpt-5-3-codexOpenAI-compatible clients$0.70 / $5.60

A typical agentic step is roughly 25,000 input and 1,200 output tokens, so a 20-step task lands around $0.74 on claude-sonnet-4-6 at these rates. Put your own numbers through the cost calculator rather than trusting a single worked example — output-heavy work shifts the ranking, because output rates differ more between these models than input rates do.

Custom endpoints: a real asymmetry

Both tools support a third-party endpoint, but not equally, and this is the most practical difference between them today.

Claude Code reads ANTHROPIC_BASE_URL and speaks the Anthropic Messages API, which many providers serve. Pointing it elsewhere is three environment variables and no extra software (setup guide).

Codex CLI is stricter. Its model_providers block has a wire_api key, and the current configuration reference lists responses as the only supported value — meaning a custom provider must serve OpenAI's Responses API at /v1/responses, not the far more common /v1/chat/completions:

config.toml
# ~/.codex/config.toml — wire_api accepts only "responses"
[model_providers.example]
base_url = "https://api.example.com/v1"
env_key  = "EXAMPLE_API_KEY"
wire_api = "responses"        # requires POST /v1/responses upstream

# A provider that serves only /v1/chat/completions cannot be
# configured here today, whatever base_url you give it.

That rules out most OpenAI-compatible gateways, including Kunavo, which serves /v1/chat/completions but not /v1/responses. So while gpt-5-3-codex is available here and runs fine in OpenAI-compatible clients such as Cursor, Kilo Code and Cline, it cannot currently be driven from Codex CLI via Kunavo. Codex CLI against a custom endpoint needs a provider that exposes the Responses API. We would rather say that plainly than sell you a config block that returns 404.

Claude Code has no such constraint, which is worth weighing if running on your own endpoint — for cost, routing or governance — is part of why you are choosing between them at all.

Can either drive the other's models?

Not cleanly, and it's usually not worth forcing. Claude Code expects Claude-family slugs on the Messages API; Codex CLI expects the OpenAI-compatible surface. A local router can translate between them, at the cost of another moving part and some feature loss — prompt caching in particular passes through untranslated only on the native route.

The simpler approach is to run each tool against the model family it was designed for and switch tools rather than protocols. If you do want multi-provider routing inside one CLI, the Claude Code router guide covers when that's worth the setup and when a base-URL swap does the job instead.

FAQ

Which writes better code?

It depends on the task, the language and the repository, and it changes with every model release. Anyone claiming a durable general winner is overreaching. Run both on your own work — that result is the only one that transfers.

Do I have to pick one?

No. They're separate binaries with separate config and don't conflict. Plenty of people keep both installed and reach for whichever suits the task.

Is either one free?

Both CLIs are free to install; neither is free to run, because every step is a paid model call. See is Claude Code free for how the subscription and per-token routes actually compare.

What about Cursor, Kilo Code and Cline?

Those are editor extensions rather than terminal agents, and they take an OpenAI-compatible base URL in a settings field. See the Kilo Code, Cline and Roo Code guide.