Running the Codex CLI on Claude
Codex is OpenAI's agentic coding CLI, but its provider system is open — define a custom endpoint in config.toml and it drives Claude through AI Prime Tech instead of OpenAI. One gateway, every model (Claude, GPT, Gemini) behind a single base URL.
Add a custom provider
Codex reads ~/.codex/config.toml, shared by the CLI, the SDK, and the VS Code extension. Add a provider table and point Codex at it.
- Open
~/.codex/config.toml(create it if missing).$EDITOR ~/.codex/config.toml - Add a
[model_providers.<name>]table with the gatewaybase_url, the env var holding your key, andwire_api = "chat"(the OpenAI Chat Completions shape the gateway accepts for Claude).model = "claude-sonnet-4-5" model_provider = "aiprime" [model_providers.aiprime] name = "AI Prime Gateway" base_url = "https://aiprimetech.io/v1" env_key = "AIPRIME_API_KEY" wire_api = "chat" - Export your key into the variable named by
env_key, then launch Codex.export AIPRIME_API_KEY=<your key> codex
/v1 — Codex appends /chat/completions itself. And the provider ids openai, ollama, lmstudio are reserved, so name yours something else.Pick a model
The model field is the plain id the gateway serves — no provider prefix. Because AI Prime Tech is multi-model, you switch between a Claude, GPT, or Gemini id by changing one value.
| Setting | Value |
|---|---|
| base_url | {SITE}/v1 |
| wire_api | chat |
| model | claude-sonnet-4-5 · claude-opus-4-8 |
| env_key | name of the env var holding your key |
wire_api = "chat" works for the OpenAI-compatible surface. Some Codex builds expect "responses" — check codex --version if a request fails.Why route Codex through a gateway
Codex tasks are multi-turn loops — read, edit, run, re-read — and each turn resends context, so one task moves large token volume. Routing through AI Prime Tech gives a single billing surface and clean per-session attribution across your whole team, plus the freedom to swap models without juggling separate provider keys.
Frequently asked questions
Can Codex use Claude instead of OpenAI?
~/.codex/config.toml with the gateway base_url, wire_api = "chat", and a Claude model id. The gateway routes it to Claude.Does the base URL need /v1?
{SITE}/v1. Codex appends /chat/completions itself.Can I switch between Claude, GPT and Gemini?
model value (or keep several provider blocks) to route Codex to any model the gateway serves.What should wire_api be?
"chat" for the OpenAI-compatible surface. Verify against your Codex version if it expects "responses".Get an API key — no Anthropic account or waitlist required.
Get your API keyAI Prime Tech is an independent API gateway. It is not affiliated with, endorsed by, or a reseller of Anthropic. Claude and related model names are trademarks of their respective owners.