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 Code | Codex CLI | |
|---|---|---|
| From | Anthropic | OpenAI |
| Model family | Claude (Opus, Sonnet, Haiku) | GPT / Codex |
| API surface | Anthropic Messages | OpenAI-compatible |
| Config | Env vars + ~/.claude/settings.json | ~/.codex/config.toml |
| Custom endpoint | ANTHROPIC_BASE_URL (Messages API) | model_providers block (Responses API only) |
| Extension surface | MCP, subagents, hooks, skills, plan mode | Leaner; open-source Rust binary |
| Execution sandboxing | Permission prompts and hooks | Local sandbox policies |
| Editor integration | VS Code and JetBrains extensions | Terminal-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, skills | Claude Code |
| Plan-then-execute on large changes | Claude Code |
| Team-wide config in a committed settings file | Claude Code |
| An open-source binary you can audit | Codex CLI |
| Stricter local execution sandboxing | Codex CLI |
| To stay inside one vendor's model family | Whichever 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 — the Claude column below sits against Anthropic's official API pricing, which lists every model's per-token rate and the worked cost of a typical agentic step:
| Model | Runs in | Kunavo in / out per 1M |
|---|---|---|
claude-sonnet-4-6 | Claude Code | $1.20 / $6.00 |
claude-opus-5 | Claude Code | $2.00 / $10.00 |
claude-haiku-4-5 | Claude Code (background) | $0.40 / $2.00 |
gpt-5-3-codex | OpenAI-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:
# ~/.codex/config.toml — wire_api accepts only "responses"
model = "gpt-5-3-codex"
model_provider = "kunavo"
[model_providers.kunavo]
name = "kunavo"
base_url = "https://api.kunavo.com/v1"
env_key = "KUNAVO_API_KEY"
wire_api = "responses" # requires POST /v1/responses upstream
# A provider that serves only /v1/chat/completions still cannot be
# configured here, whatever base_url you give it.That still rules out most OpenAI-compatible gateways, which serve /v1/chat/completions and nothing else. It is the reason so many “works with any OpenAI-compatible endpoint” providers quietly fail with Codex CLI: the base URL is accepted, and every request returns 404.
Kunavo serves both surfaces — the OpenAI-compatible chat endpoint and the Responses API at /v1/responses — so the config above works as written, and gpt-5-3-codex ($0.70 / $5.60 per 1M) runs from Codex CLI as well as from Cursor, Kilo Code and Cline. The full walkthrough, including the environment variable Codex reads the key from, is in the Codex CLI API key guide.
One thing worth knowing: because Codex is bound to the protocol rather than to a model family, any chat model behind that endpoint answers — including Claude. Pointed at claude-opus-5, Codex CLI runs end to end with tool calls intact, the gateway translating Responses to the Messages API and back. The cost is that Codex's opaque reasoning items have no equivalent on a non-GPT upstream and are dropped, so the model loses its private scratchpad between turns; the visible transcript is unaffected.
So the asymmetry is narrower than it looks, but it has not disappeared: Claude Code will work against almost any Messages-API provider, while Codex CLI works only against the minority that implement Responses. That is still worth weighing if running on your own endpoint — for cost, routing or governance — is part of why you are choosing between them at all. If cost is the deciding factor, the official Anthropic API price list sets out what each Claude tier costs per 1M tokens against Anthropic's own published rate, which is the number that actually moves an agentic coding bill.
Neighbouring comparisons
Two adjacent questions this page does not answer. Codex vs ChatGPT is about which OpenAI surface to open rather than which CLI to install — the answer turns on a shared plan allowance and how fast an agent drains it. Cline vs Claude Code swaps the terminal for the editor sidebar, where the deciding difference is billing shape rather than protocol.
Can either drive the other's models?
In one direction, yes. Codex CLI can run Claude models through a gateway that serves the Responses API — it is bound to the wire protocol, not to a model family, so setting model = "claude-opus-5" in the provider block above works end to end, tool calls included. The trade-off is that Codex's opaque reasoning items are dropped on the way to a non-GPT upstream, costing the model its private scratchpad between turns.
The other direction is harder: Claude Code expects Claude-family slugs on the Messages API, so reaching GPT from it needs a local router — another moving part, and some feature loss, since cache_control passes through untranslated only on the native route. The Claude Code router guide covers when that's worth the setup and when a base-URL swap does the job instead.
Running each tool on the model family it was designed for is still the simpler default. But if you want Codex CLI's sandboxing with Claude behind it, that combination is available today — see the Codex CLI API key guide.
FAQ
What is the difference between Claude Code and Codex CLI?
Both are terminal-first agentic coding tools that read your repository, propose edits and run commands. The differences that matter in practice are the model family behind them (Claude versus GPT), the extension surface — Claude Code has MCP, subagents, hooks and skills, while Codex CLI is an open-source Rust binary with local sandboxing — and the configuration format. Neither is strictly better; they suit different workflows and both can run against a custom endpoint.
Can I use Claude Code and Codex CLI at the same time?
Yes — they are separate binaries with separate configuration and do not conflict. They differ in how freely you can point them at a custom endpoint: Claude Code reads ANTHROPIC_BASE_URL and speaks the Anthropic Messages API, while Codex CLI's model_providers block supports only wire_api = responses, so a custom provider must serve OpenAI's Responses API rather than the more common chat completions endpoint. A gateway that serves both — Kunavo does — can drive either CLI from one key.
Which is cheaper, Claude Code or Codex CLI?
Cost is set by the model and the number of agentic steps, not by the CLI itself. Both tools resend context on every step, so the per-token rate compounds the same way in each. Compare the specific models you would actually run rather than the tools, and weigh output rates as well as input rates, since output-heavy agentic work shifts the ranking between model families.
Can Codex CLI use Claude models, or Claude Code use GPT models?
Codex CLI can run Claude models through a gateway that serves the Responses API: it is bound to the wire protocol, not to a model family, so with model = claude-opus-5 it runs end to end including tool calls. The reverse is harder — Claude Code expects Claude-family slugs on the Messages API, and reaching GPT from it needs a local router. Running each tool on the model family it was designed for is still the simpler default, but the Codex-to-Claude direction genuinely works.
How do I choose between Claude Code and Codex CLI?
Pick on workflow fit rather than benchmarks. Choose Claude Code if you want MCP servers, subagents, hooks or plan mode, or if your team already standardises on settings files. Choose Codex CLI if you want an open-source binary you can audit, or stricter local execution sandboxing. Both are cheap enough to install side by side and evaluate on a real task from your own repository, which beats any published comparison.
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 rather than an environment variable. Each has its own setup and its own model-routing feature: Cline (Plan/Act split), Roo Code (a configuration profile per mode) and Kilo Code.