Claude Code vs Codex

Claude Code vs Codex: API Protocol, Configuration and Workflow

Claude Code (Anthropic) and Codex CLI (OpenAI) are both terminal AI coding agents, but they use different API protocols and configuration. Knowing the differences avoids setup mistakes and lets a team run both side by side.

Get started · View pricing

Claude Code

Anthropic Messages API (/v1/messages); set ANTHROPIC_BASE_URL (no /v1) and ANTHROPIC_AUTH_TOKEN in ~/.claude/settings.json; uses Claude models.

Codex CLI

OpenAI Responses API (/v1/responses); configure ~/.codex/config.toml (base_url with /v1, wire_api = "responses") plus auth.json; uses GPT models.

One gateway for both

gw-link serves both protocols, so one account issues a key per tool and tracks balance, caps and usage together.

Choosing and running both

  1. Decide which tool and models your team prefers — installing both is fine.
  2. Claude Code: set ANTHROPIC_BASE_URL=https://gw-link.com and your key.
  3. Codex: set base_url = https://gw-link.com/v1 and wire_api = "responses" in config.toml.
  4. Create a key per tool so usage and cost are tracked separately.

Configuration examples

Claude Code (~/.claude/settings.json)

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://gw-link.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-gw-link-key",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

Codex (~/.codex/config.toml)

model_provider = "OpenAI"
model = "gpt-5.5"
review_model = "gpt-5.5"
disable_response_storage = true

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://gw-link.com/v1"
wire_api = "responses"
requires_openai_auth = true

FAQ

Do I have to pick one?

No. Their config files don't conflict, and both can run on the same gw-link account.

How do the base URLs differ?

Claude Code uses the root https://gw-link.com (it appends /v1/messages). Codex needs https://gw-link.com/v1 (it only appends /responses).

Can they share one key?

A key's models are set by its group. Usually create one key per tool on the matching group so usage is tracked separately.

中文版

Last updated: