> Markdown mirror of https://router.one/blog/claude-code-vs-codex-cli for AI assistants and crawlers. Router One is an OpenAI-compatible LLM API gateway.
> Published: 2026-08-02 · Last updated: 2026-09-19 · Author: Router One Team

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

_A workflow-first comparison of Claude Code and Codex CLI — protocols, model families, autonomy vs sandboxing, and running both through one Router One wallet._

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](https://router.one/blog/cursor-vs-claude-code) first. This post assumes you've already decided you want the terminal. If a third terminal agent belongs on your shortlist, [OpenCode vs Claude Code vs Codex CLI](https://router.one/blog/opencode-vs-claude-code-vs-codex-cli) adds OpenCode to this same comparison.

## 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 — see [Codex and the Responses API](https://router.one/codex-responses-api). 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 family on one config.** GPT-5.5 is the strong generalist; GPT-5.6 Terra is listed at a lower rate for small, well-scoped edits, and GPT-6 Astra sits at the top of the range — switching is one `model` line.

## 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 only reaches the models that speak its own protocol.**

Claude Code uses the Anthropic Messages endpoint and currently listed Claude models. Codex CLI uses native Responses and currently listed GPT models, including GPT-6 Astra and the GPT-5.6 family. DeepSeek V4 Pro and Flash are no longer listed as of 2026-09-05; their historical support on both endpoints is not current availability. Check each model’s endpoint list before configuring either CLI.

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 Code | Codex CLI |
| --- | --- | --- |
| Vendor | Anthropic | OpenAI |
| Protocol | Anthropic Messages | OpenAI Responses (`wire_api = "responses"`) |
| Models via Router One (2026-09-19 catalog) | Claude Opus 5, Claude Opus 4.8, Claude Sonnet 5, Claude Haiku 4.5 | GPT-5.5, GPT-5.6 Sol and Terra, GPT-6 Astra |
| Execution posture | Autonomous by default, long unattended stretches | Sandbox-first, explicit approval modes |
| Extension surface | Hooks, skills, `CLAUDE.md` | `config.toml` profiles, `AGENTS.md` |
| Best at | Multi-file refactors, run-fix-rerun loops | Contained tasks, cautious environments, fast small edits |
| Billing through Router One | Pay per token from the shared wallet | Same wallet, same traces |

## Setting up both through Router One

Both configurations take about two minutes, and the [one-click install commands](https://router.one/docs/guides/cli-setup) do them for you. Manually, Claude Code is an environment pair — the base URL plus your key sent as the bearer token:

```bash
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:

```toml
model = "openai/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](https://router.one/docs/guides/cli-setup) has the complete version of both, including Windows. OpenCode, the third terminal agent, points at the same key — the [OpenCode setup guide](https://router.one/integrations/opencode) has its config.

## 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.
- **Check each request's cost.** Dashboard → Logs records the model, request ID, tokens, cost, latency, and status. Save request IDs alongside the tool name in your client or application logs to reconcile workload costs. The [cost tracking page](https://router.one/llm-cost-tracking) describes the available fields.
- **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](https://router.one/models). If you prefer a flat monthly number, Pro/Max/Ultra subscriptions exist alongside the wallet ([pricing](https://router.one/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](https://router.one/blog/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](https://router.one/claude-code-china) and [Codex CLI in China](https://router.one/codex-china).

## FAQ

**Can Claude Code use GPT models through Router One, or Codex CLI use Claude models?**
No. Claude Code uses the Messages endpoint for listed Claude models; Codex CLI uses Responses for listed GPT models. The account, wallet, keys, and per-request traces are shared. A shared gateway does not make a Claude model callable through Responses or a GPT model callable through Messages.

**Can I run Claude Code and Codex CLI on the same Router One account?**
Yes. One wallet can fund both tools. Create a separate API key for each tool and set its own maxSpend cap; save request IDs with tool names when you need workload cost attribution.

**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?**
Dashboard → Logs records the model, request ID, tokens, cost, latency, and status. Match those request IDs with tool names saved in your client or application logs to attribute costs.

**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](https://router.one/claude-code-china) and [/codex-china](https://router.one/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 family — GPT-5.5 for general work, the lower-rate GPT-5.6 Terra for small edits — fits 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](https://router.one/), install either tool with the [one-click setup](https://router.one/docs/guides/cli-setup), and let two weeks of real work — not a benchmark table — make the call.

## See also

- Canonical page: https://router.one/blog/claude-code-vs-codex-cli
- Codex CLI China: https://router.one/codex-china
- All blog posts: https://router.one/blog
- Models and per-model token rates: https://router.one/models (markdown: https://router.one/models.md)
- Pricing: https://router.one/pricing
- API docs (markdown): https://router.one/docs.md
- Company facts: https://router.one/facts/company.md
