Home / Learn / Codex CLI with a custom provider: config.toml, GPT and Claude models, IDE extension and fixes
Codex CLI. A charcoal terminal window connected to a small compass-like routing dial and two neatly separated provider cards.

Codex CLI with a custom provider: config.toml, GPT and Claude models, IDE extension and fixes

Codex reads one file, ~/.codex/config.toml, shared by the CLI, codex exec and the IDE extension. A custom provider in that file points Codex at this gateway, where the same setup runs GPT models and Claude models. Current Codex versions speak only the Responses API (wire_api = "responses"), so older guides that use wire_api = "chat" no longer work.

Install Codex

terminal
# macOS / Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# or with a package manager
npm install -g @openai/codex
brew install --cask codex

codex --version
Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

The Codex extension for VS Code, Cursor and Windsurf installs from the editor's extension marketplace and uses the same ~/.codex/config.toml as the CLI, so everything below applies to both.

Use a key from the right group

A gateway key belongs to one group, and the group decides which models the key can call. For GPT models, create the key in the **Codex** group in the dashboard. For Claude models, any Claude pay-as-you-go key works. A key from an Unlimited group needs an active plan; without one, every request fails with No active subscription found for this group.

~/.bashrc or ~/.zshrc
export AIPRIME_CODEX_KEY=key_from_the_codex_group    # GPT models
export AIPRIME_CLAUDE_KEY=key_from_a_claude_group    # Claude models
Windows
setx AIPRIME_CODEX_KEY "key_from_the_codex_group"
setx AIPRIME_CLAUDE_KEY "key_from_a_claude_group"
# open a new terminal afterwards

config.toml for GPT models

~/.codex/config.toml
model_provider = "aiprime"
model = "gpt-6-astra"
model_reasoning_effort = "high"

[model_providers.aiprime]
name = "AI Prime Tech"
base_url = "https://aiprimetech.io/v1"
env_key = "AIPRIME_CODEX_KEY"
wire_api = "responses"
supports_websockets = false
Setting Why
[model_providers.aiprime]Any id except the reserved openai, ollama and lmstudio
base_url = "https://aiprimetech.io/v1"Codex appends /responses to it
env_keyThe **name** of the environment variable that holds the key, not the key itself
wire_api = "responses"The only value current Codex accepts
supports_websockets = falseKeeps Codex on plain HTTP streaming, which works through any proxy or VPN
Don't add requires_openai_auth = true or experimental_bearer_token to this provider. With requires_openai_auth = true Codex ignores env_key and sends your ChatGPT or OpenAI login instead, which the gateway rejects.

Run Codex on Claude models

The gateway accepts Responses API requests for Claude models and translates them, so Codex can drive Claude as well. Add a second provider that uses your Claude key, then a profile to switch to it.

~/.codex/config.toml (add below the first provider)
[model_providers.aiprime_claude]
name = "AI Prime Tech (Claude)"
base_url = "https://aiprimetech.io/v1"
env_key = "AIPRIME_CLAUDE_KEY"
wire_api = "responses"
supports_websockets = false
~/.codex/claude.config.toml
model_provider = "aiprime_claude"
model = "claude-sonnet-5"
model_reasoning_effort = "high"
terminal
codex --profile claude
codex exec --profile claude "review the last commit for bugs"

Since Codex 0.134.0 a profile is its own file, ~/.codex/<name>.config.toml, with its keys at the top level; [profiles.<name>] tables inside config.toml are no longer read. Profiles and providers can only be set in your user config: a project's .codex/config.toml ignores model_provider and model_providers.

Models and reasoning effort

Model ID Provider Use it for
gpt-6-astraCodex group keyThe strongest GPT model on the gateway; long agent tasks
gpt-6-solCodex group keyFaster and cheaper GPT for routine coding
gpt-5.6-terraCodex group keyLight tasks and quick edits
claude-sonnet-5Claude keyDefault Claude for coding work
claude-opus-5-5Claude keyHarder reasoning and large refactors
claude-fable-5-1Claude keyMost capable and most expensive

model_reasoning_effort accepts low, medium, high, xhigh or max, depending on the model. Don't set none: these models reject it with 'none' is not supported. review_model sets a different model for /review if you want one. The dashboard shows every model your key's group can call.

IDE extension and codex exec

The IDE extension reads the same config.toml, but env_key is resolved from the editor's own environment. An editor started from the dock or Start menu does not see variables exported in .bashrc, and Codex then fails with Invalid API key while the CLI works. Set the variable system-wide (on Windows setx does this), or start the editor from a terminal, e.g. code ..

codex exec runs one task without the interactive UI, which suits scripts and CI. It uses the same config and profiles:

terminal
codex exec "write unit tests for utils.py"
codex exec --profile claude "summarise the changes on this branch"
codex login status        # which authentication method is active

Retries and timeouts

Each provider has its own retry and stream settings. The defaults are 4 request retries, 5 stream reconnects and a 5-minute idle timeout per stream. Long reasoning turns can sit silent for a while, so raising the idle timeout helps on high effort levels.

~/.codex/config.toml
[model_providers.aiprime]
# ...settings from above...
request_max_retries = 6
stream_max_retries = 8
stream_idle_timeout_ms = 600000

Troubleshooting: errors Codex users hit

The errors below are the ones Codex clients actually produce on this gateway, most common first.

What you see Cause Fix
403 No active subscription found for this groupThe key belongs to an Unlimited group with no active planUse a key from a pay-as-you-go group (Codex for GPT), or buy a plan
401 Invalid API keyThe variable is empty in the process running Codex (often the IDE), or requires_openai_auth = true made Codex send another loginecho $AIPRIME_CODEX_KEY; remove requires_openai_auth; restart the editor
404 Model "..." is not supported by any configured account in this groupThe model doesn't belong to the key's group, e.g. a Claude model with a GPT keySwitch provider or profile so the key matches the model
426 WebSocket upgrade requiredThe WebSocket transport is on but the connection was not upgradedsupports_websockets = false, and remove responses_websockets_v2 from [features]
403 Your API key has expiredThe key was created with an expiry dateCreate a new key in the dashboard
'none' is not supportedReasoning effort set to noneUse low or higher
404 page not foundbase_url contains /v1 twiceUse exactly https://aiprimetech.io/v1
Config error about wire_api after an upgradeA wire_api = "chat" line from an old guideSet wire_api = "responses"
Your balance is used upBalance is emptyTop up
Concurrency limit exceeded for userSeveral Codex agents or windows running at onceRun fewer in parallel, or ask support for higher concurrency

Comparing Codex with Claude Code before you commit to one? See Claude Code vs Codex.

Frequently asked questions

Where is the Codex config file?
~/.codex/config.toml (or $CODEX_HOME/config.toml). The CLI, codex exec and the IDE extension all read it. A project's .codex/config.toml cannot set providers.
Can Codex CLI use Claude models?
Yes, through a gateway that accepts Responses API requests for Claude models. Add a provider with a Claude key and set model to an ID such as claude-sonnet-5.
Does wire_api = "chat" still work in Codex?
No. The Codex config reference lists responses as the only supported value, and it is the default when omitted.
Why does the Codex VS Code extension say invalid API key when the CLI works?
env_key is read from the editor's environment. Set the variable system-wide or start the editor from a terminal where it is exported.
What does 'No active subscription found for this group' mean in Codex?
The key belongs to a subscription (Unlimited) group with no active plan. Use a key from a pay-as-you-go group or buy a plan.
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 explained: a Claude model comparison of Claude Opus vs Sonnet vs Haiku vs Fable — all Claude API models, Anthropic model names and prices (2026)Paying 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 CodeOpenCode config for Claude: opencode.json setup, models and common errorsRunning an Unlimited Hermes Agent on ClaudeRunning Unlimited OpenClaw on ClaudeWhat an Anthropic-Compatible API MeansClaude Code API key — ANTHROPIC_API_KEY: how to get it, set it up, and when to use claude setup-token insteadClaude Code API Costs — Pricing and How to Cut ThemClaude API errors explained: server error 500, overloaded 529, rate limit 429, bad request 400 — and the fix for eachHow to buy Claude API credits — and why a Claude credit beats any "buy Claude account" offerClaude free API: is there a free Claude API key, and what is actually free in 2026?Claude 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 ClaudeChatAnthropic in LangChain: import, base_url, streaming, tools and errorsAnthropic Python SDK: install, set base_url, stream, and handle errorsClaude with the Vercel AI SDK: createAnthropic baseURL, streaming and fixesRun Factory Droid on ClaudeThe Claude Code API, ExplainedIntegrating the Claude API Into Your ApplicationHow to get unlimited Claude usage — and why there is no "Claude Code cracked"