Running the Codex CLI on Claude
Codex is OpenAI's agentic coding CLI, but its provider system is open — define a custom endpoint and it will drive Claude just as readily. Through AI Prime Tech you reach Claude, GPT, and Gemini behind one base URL, so Codex becomes a front-end to whichever model fits the task.
The custom-provider block
Codex configuration lives in ~/.codex/config.toml, shared by the CLI, the SDK, and the VS Code extension. Add a [model_providers.<name>] table with the gateway base_url, the env_key that holds your key, and the wire protocol, then select it with model_provider at the top.
Because AI Prime Tech is multi-model, you can keep several provider entries or simply swap the model value between a Claude, GPT, or Gemini id the gateway exposes — one config, every model.
Base URL and wire_api
Give the base URL with /v1; Codex appends the route itself. Set wire_api = "chat" so it speaks the OpenAI Chat Completions shape, which the gateway's OpenAI-compatible surface accepts for Claude models.
Provider ids openai, ollama, and lmstudio are reserved — name your provider something else. These keys are read from the user-level config.toml, not a project-local copy.
Model routing across providers
The model field is the plain id the gateway serves, with no prefix — claude-sonnet-4-5, claude-opus-4-8, or a GPT/Gemini id. Export your key into the variable named by env_key.
For an engineering team this is the appeal: one Codex install, one gateway, and you route by changing a single value rather than juggling separate API keys per provider.
Token cost on agentic runs
Codex tasks are multi-turn loops — read, edit, run, re-read — and each turn resends context, so a single task can move large token volume. On metered pricing that is hard to predict.
Running Codex through a gateway gives you one billing surface and clean per-session attribution, so you can see exactly which agentic runs cost what across the whole team.
# ~/.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"
# export AIPRIME_API_KEY=<your key>
Frequently asked questions
Can Codex use Claude through AI Prime Tech?
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 in Codex?
Yes — AI Prime Tech is multi-model, so change the model value (or keep multiple provider blocks) to route Codex to any model the gateway serves.
What is wire_api set to?
"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.