Router One
Back to Blog

Claude Code vs Codex CLI: Which Terminal Agent in 2026?

PublishedRouter One Team

Claude Code and Codex CLI are the two terminal coding agents most engineers actually shortlist in 2026. From a distance they look alike — both live in your terminal, read your repo, edit files, and run commands — but they speak different protocols, reach different model families, and reward different working styles. This comparison is about daily engineering work, and it ends in a pick-by-workflow verdict rather than a crowned winner. It also covers the part most comparisons skip: running both through one Router One account, so trying them side by side doesn't require holding two subscriptions.

One scoping note up front: both of these are terminal agents, not editors. If your real question is "agent in the terminal vs AI in the IDE," read Cursor vs Claude Code first. This post assumes you've already decided you want the terminal.

Two agents, two philosophies

Claude Code is Anthropic's terminal agent. You run claude in a repo, describe a task, and it explores the codebase on its own — reading files, editing them, running tests, fixing failures, iterating. Its default posture is "do the work, then show you the diff": it asks at tool-use boundaries, but it is built for long autonomous stretches that touch fifteen files before coming back to you.

Codex CLI is OpenAI's terminal agent. Two things define it. First, it is native to the Responses API wire format — the newer protocol OpenAI built for agentic tool use — rather than classic Chat Completions, which is why many generic relays fail with it while a gateway that implements wire_api = "responses" works. Second, its execution model is sandbox-first: commands run inside a sandbox with explicit approval modes, and the agent has to ask before escalating. The leash is shorter by design.

That difference in default posture is the honest one-line summary: Claude Code optimizes for autonomy, Codex CLI optimizes for containment. Which one is "better" depends entirely on whether the task in front of you deserves a delegate or a supervised executor.

What each tool is actually good at

Claude Code's strengths:

  • Deep multi-file agentic edits. It holds a plan across a whole module — refactors that touch 15–30 files, iterate-until-tests-pass loops, migrations that need the same idea applied consistently everywhere.
  • The hooks and skills ecosystem. Hooks fire shell commands at lifecycle events (before/after tool use), skills package repo-specific workflows into reusable commands, and CLAUDE.md gives every session standing project context. Teams that invest here get an agent that behaves like it has been onboarded.
  • Terminal-native, editor-agnostic. It operates at the filesystem level, so it pairs with Vim, VS Code, or anything else; you review with git diff.

Codex CLI's strengths:

  • Responses-API native. Structured tool calls and reasoning summaries come through the protocol as first-class objects, not as prompt conventions layered on Chat Completions.
  • Sandboxed execution style. The approval-mode model makes it comfortable to run on codebases where an unsupervised rm or an accidental push would be expensive. It is the easier tool to hand to someone cautious.
  • The GPT-5.x Codex models. GPT-5.5 is the strong generalist; GPT-5.3 Codex Spark is tuned for fast, cheap coding turnaround — a genuinely different speed class for small tasks.

The model boundary, stated honestly

Here is the part vendors blur and we won't. Through Router One, one account, one wallet, and one gateway key serve both tools — but each tool stays inside its own model family.

Claude Code speaks the Anthropic protocol, so through Router One's Anthropic-compatible endpoint it reaches Claude-family models only: Claude Opus 4.8 for the hardest work, Claude Sonnet 5 as the daily driver, Claude Haiku 4.5 when cost matters most. Codex CLI speaks the Responses protocol, so it reaches GPT-family models only: GPT-5.5, GPT-5.4 and GPT-5.4 mini, and GPT-5.3 Codex Spark. There is no cross-protocol bridge — you cannot point Claude Code at GPT-5.5 or Codex CLI at Claude Sonnet 5, and any gateway claiming otherwise is describing a translation layer these tools don't actually support.

What is shared is everything around the calls: the same wallet funds both, the same dashboard shows both, and per-request traces record what each tool spent. That's the practical meaning of "one gateway for both."

Side by side

Claude CodeCodex CLI
VendorAnthropicOpenAI
ProtocolAnthropic MessagesOpenAI Responses (wire_api = "responses")
Models via Router OneClaude Opus 4.8, Claude Sonnet 5, Claude Haiku 4.5GPT-5.5, GPT-5.4, GPT-5.4 mini, GPT-5.3 Codex Spark
Execution postureAutonomous by default, long unattended stretchesSandbox-first, explicit approval modes
Extension surfaceHooks, skills, CLAUDE.mdconfig.toml profiles, AGENTS.md
Best atMulti-file refactors, run-fix-rerun loopsContained tasks, cautious environments, fast small edits
Billing through Router OnePay per token from the shared walletSame wallet, same traces

Setting up both through Router One

Both configurations take about two minutes, and the one-click install commands do them for you. Manually, Claude Code is an environment pair — the base URL plus your key sent as the bearer token:

export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-api-key

Codex CLI is a custom provider in ~/.codex/config.toml using the env_key mechanism — the config names an environment variable, and Codex reads your Router One key from it:

model = "gpt-5.5"
model_provider = "router"

[model_providers.router]
name = "Router One"
base_url = "https://api.router.one/v1"
wire_api = "responses"
env_key = "ROUTER_ONE_API_KEY"

Then export ROUTER_ONE_API_KEY=sk-your-api-key in your shell profile. The CLI setup guide has the complete version of both, including Windows.

Cost: one wallet instead of two subscriptions

Run natively, these tools sit on two separate vendor relationships — two billing pages, two payment methods, two places to check what you spent. Through Router One both become pay-per-token against one prepaid wallet, which changes three practical things:

  • Trying both is cheap. Create one key per tool, set a maxSpend hard cap on each — say $10 — and run a real week of work through each agent. When a key hits its cap it stops; your wallet and the other key are untouched.
  • You can see which tool burned what. Per-request traces record the final model and provider, tokens, cost, latency, and status (Dashboard → Logs). With one key per tool, "was that $6 day Claude Code or Codex?" is a filter, not a guess. The cost tracking page describes exactly what the ledger records.
  • Rates are the posted per-token line. Pricing starts as low as 10% of official provider list prices (up to 90% off) on select models — live per-model rates are on the models page. If you prefer a flat monthly number, Pro/Max/Ultra subscriptions exist alongside the wallet (pricing).

One reliability note that applies to both tools: when an eligible upstream error occurs — a 5xx, timeout, 429, or 529 — Router One can retry the request on another healthy provider serving the same requested model. Not every error is retryable and this is not a zero-downtime guarantee; long agent sessions should still tolerate the occasional failed call and use bounded exponential backoff on retries.

For the Codex-specific version of this argument — why a coding CLI doesn't need a consumer chat subscription at all — see Codex CLI without ChatGPT Plus.

Using both from mainland China

Both tools call vendor endpoints that are unreliable from Chinese ISPs without a VPN, and both vendors bill in ways that assume a foreign card. Router One's endpoints are directly reachable from mainland China with no VPN, and the wallet tops up by card or Alipay through one hosted checkout, or USDT/USDC on six chains (Tron, BSC, Ethereum, Polygon, Base, Arbitrum) — no US credit card required. The dedicated setup pages are Claude Code in China and Codex CLI in China.

FAQ

Can Claude Code use GPT models through Router One, or Codex CLI use Claude models? No. Each tool stays inside its own model family: Claude Code speaks the Anthropic protocol and reaches Claude models only, while Codex CLI speaks the OpenAI Responses protocol and reaches GPT models only. The account, wallet, keys, and per-request traces are shared — the model families are not.

Can I run Claude Code and Codex CLI on the same Router One account? Yes — that is the intended setup. One wallet funds both tools; the practical recommendation is one API key per tool, each with its own maxSpend hard cap, so per-request traces cleanly attribute which tool spent what.

Do I need a Claude subscription or ChatGPT Plus to use these CLIs? No. Through Router One both tools bill per token from a prepaid wallet at posted per-model rates, with no consumer subscription on either side. Router One's own Pro/Max/Ultra plans exist as an optional flat-rate alternative for heavy users.

How do I see which tool spent what? Every request through Router One is traced with the final model and provider, tokens, cost, latency, and status, visible in the dashboard under Logs. If each tool uses its own key, filtering by key gives an exact per-tool spend breakdown with no estimation involved.

Do both tools work from mainland China? Yes, when pointed at Router One: the endpoints are directly reachable from the mainland without a VPN, and the wallet tops up via card or Alipay through a hosted checkout, or stablecoins on six chains. The China-specific setup guides are at /claude-code-china and /codex-china.

Verdict: pick by workflow, not by brand

There is no winner to crown, and anyone crowning one is reviewing their own habits. The honest mapping:

  • Default to Claude Code if your work is dominated by multi-file changes in an established codebase, you want run-tests-fix-rerun loops handled without supervision, or your team is willing to invest in hooks, skills, and CLAUDE.md to encode its conventions.
  • Default to Codex CLI if you value the sandbox-first execution model, your tasks are mostly contained and well-scoped, or the GPT-5.x Codex models — especially GPT-5.3 Codex Spark's speed on small edits — fit your rhythm.
  • Run both if you can. They don't conflict, and through one Router One wallet with a capped key each, the experiment costs exactly what the traces say it cost.

Set up a key at router.one, install either tool with the one-click setup, and let two weeks of real work — not a benchmark table — make the call.

Related canonical pages

This article belongs to the Codex CLI China cluster. These pages are the commercial page, setup docs, evidence source, and trust references.

Related reads