Home / Learn / Running the Codex CLI on Claude
Running the Codex CLI on Claude — Codex Guide

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.

  1. Open ~/.codex/config.toml (create it if missing).
    terminal
    $EDITOR ~/.codex/config.toml
  2. Add a [model_providers.<name>] table with the gateway base_url, the env var holding your key, and wire_api = "chat" (the OpenAI Chat Completions shape the gateway accepts for Claude).
    ~/.codex/config.toml
    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"
  3. Export your key into the variable named by env_key, then launch Codex.
    terminal
    export AIPRIME_API_KEY=<your key>
    codex
The base URL must end in /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_apichat
modelclaude-sonnet-4-5 · claude-opus-4-8
env_keyname 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?
Yes. Add a custom provider in ~/.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?
Yes — use {SITE}/v1. Codex appends /chat/completions itself.
Can I switch between Claude, GPT and Gemini?
Yes — AI Prime Tech is multi-model, so change the 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".
Start using Claude in minutes

Get an API key — no Anthropic account or waitlist required.

Get your API key

AI 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.

More Claude API guides

How to Get a Claude API KeyClaude API Pricing, ExplainedThe Cheapest Way to Use the Claude APIUnlimited Cursor with the Claude APIUnlimited Claude Code AccessClaude API Gateway vs. Anthropic DirectUsing Claude Through an OpenAI-Compatible APIClaude Models ComparedPaying for the Claude API with CryptoClaude API Access Without a WaitlistHow to Reduce Claude Token UsageUnlimited Cline with the Claude APIUnlimited Roo Code with the Claude APIUnlimited Claude in JetBrains IDEsUnlimited Aider with the Claude APIUnlimited Claude in VS CodeUnlimited OpenCode with the Claude APIRunning an Unlimited Hermes Agent on ClaudeRunning Unlimited OpenClaw on ClaudeWhat an Anthropic-Compatible API MeansClaude Code API Key — How to Get and Set UpClaude Code API Costs — Pricing and How to Cut ThemClaude API Errors — Rate Limits, 400, 500, 529 FixesHow to Buy Claude API CreditsClaude API Free Trial — Get $5 Free CreditClaude API vs Claude Pro/Max Subscription — Which to ChooseConnecting Claude to n8nRouting LiteLLM to ClaudeUsing Claude in Kilo CodeBring Claude into GitHub CopilotWire Zed to Claude Through the GatewayConnect Cherry Studio to ClaudePoint LangChain at Claude on the GatewayRun Factory Droid on ClaudeThe Claude Code API, ExplainedIntegrating the Claude API Into Your Application