An Anthropic Messages-API-compatible HTTP proxy, written in Rust, that lets Claude Code drive OpenAI / Codex models through your existing ChatGPT (Codex) subscription.
Claude Code talks Anthropic /v1/messages; the proxy translates each request
into an OpenAI Responses API call against the Codex backend
(chatgpt.com/backend-api/codex), using the OAuth tokens the codex CLI
already stores in ~/.codex/auth.json, and streams the answer back as
Anthropic SSE. No Codex app-server, no OpenAI API key.
- Rust toolchain (
cargo). - The Codex CLI, logged in with a ChatGPT account:
codex login. The proxy reads (and, when the access token expires, refreshes and rewrites) onlyauth.jsonunder the Codex home directory.
cargo run --release -- --auth-token secretThen, in another terminal:
ANTHROPIC_BASE_URL="http://127.0.0.1:8787" \
ANTHROPIC_AUTH_TOKEN="secret" \
ANTHROPIC_API_KEY="" \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 \
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-gpt-6-astra \
ANTHROPIC_DEFAULT_SONNET_MODEL=claude-gpt-6-astra \
ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-gpt-5.6-luna:low \
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1 \
claudeClaude Code fetches GET /v1/models | Anthropic-shaped list of claude-<slug> ids — one entry
per MAIN base model (no :effort variants; effort is a request parameter)
caches the list in ~/.claude/cache/gateway-models.json, and lets you pick
any of the proxied models with /model.
Claude Code only keeps gateway models whose id contains claude, so every
Codex model is exposed as claude-<codex slug>; the proxy strips the prefix
before calling upstream (bare slugs are accepted too). An optional
:<effort> suffix pins the reasoning effort, e.g. claude-gpt-6-astra:low,
claude-gpt-6-astra:xhigh. Efforts are clamped to what the model supports.
The advertised lineup is one entry per base model, curated from what the backend itself describes as its primary lineup (each verified by real inference):
| Public id | Backend slug |
|---|---|
claude-gpt-6-astra |
gpt-6-astra (frontier) |
claude-gpt-6-sol |
gpt-6-sol |
claude-gpt-6-luna |
gpt-6-luna |
claude-gpt-6.1-sol |
gpt-6.1-sol |
claude-gpt-5.6-sol |
gpt-5.6-sol (workhorse) |
claude-gpt-5.6-terra |
gpt-5.6-terra (balanced) |
claude-gpt-5.6-luna |
gpt-5.6-luna (fast) |
Legacy (gpt-5.5), reserve (gpt-reserve) and auxiliary
(codex-auto-review) slugs stay resolvable by direct id but are not
advertised; a main slug the backend momentarily does not list is still
advertised in the picker (inference waits for the backend to expose it).
Effort precedence: the request's output_config.effort (the native Claude Code
effort control), then the :<effort> id suffix, then the request's
thinking.budget_tokens, then --default-reasoning-effort, clamped to what
the model advertises.
CLAUDE_CODEX_CHAIN is a comma-separated list of Codex slugs in preference
order:
CLAUDE_CODEX_CHAIN="gpt-6-astra,gpt-5.6-sol,gpt-5.6-terra" \
cargo run --release -- --auth-token secretWhen the selected model fails with a transient upstream error (429/5xx), the proxy retries the request with the next chain entry after it — same Codex backend, same ChatGPT account, never a paid API or another provider.
- Quota exhaustion never chains. "usage limit" is an account-level terminal
state: every model would fail identically, so the terminal error surfaces
immediately with
retry-after: 3600, on any attempt. - Circuit breaker. A candidate that failed with 429/5xx is skipped for 60s (per-slug cooldown). The selected model is never keyed — it is always attempted first.
- Loud, never silent. Every switch logs a
warnnaming the original slug, the failing status, the new slug and the remaining candidates; exhaustion is logged too, and the per-attempt "model resolution" line shows the slug actually used. - Effort is re-resolved per candidate, from the request-level channels
(
output_config.effort,thinking) or the CLI default, clamped to what the candidate declares — the selected model's:effortsuffix does not carry over. - Off by default. Unset or empty = the feature is fully disabled and behavior is identical to a no-chain build. A chain entry that does not resolve in the catalog is skipped with a warning.
- Lenient parsing, strict behavior. Entries are trimmed; empty and duplicate entries are dropped at startup (first occurrence wins).
The release profile (opt-level = 3, LTO, codegen-units = 1, panic = "abort", strip) plus a deliberately minimal dependency tree keep the
binary small: 8.8 MB naive → 3.7 MB release → 1.4 MB after UPX.
- 10 direct dependencies (
axum,bytes,futures-core,log,reqwest,serde,serde_json,thiserror,tokio,tokio-stream):anyhow,chrono,clap,tracing(+subscriber),uuid,env_loggerandfutures-utilwere replaced by ~175 lines of std-only code (util.rs) and a ~35-line stderr logger. axumwithdefault-features = false(http1,json,tokioonly): drops the transitivetracingtree axum 0.7 pulls in by default.futures-coreinstead offutures-util: only theStreamtrait;.next()comes from the already-presenttokio_stream.- Granular tokio features (
rt,macros,net,time,sync,fs) instead offull; reqwest without its default feature set (rustls, no gzip/deflate/brotli).
cargo build --release
upx --best --lzma target/release/claudecodex # optionalsrc/ proxy source (lib + bin split)
tests/ hermetic integration suite (mock upstream) + regression.sh
deploy/ launcher, multi-backend router, picker generator, systemd unit
docs/ architecture, test plan, research notes