Codex config.toml for a Custom API Provider: Responses Only Since 2026
Wokey Team · 2026-09-24
Short answer: to point Codex at a third-party API, define a custom provider in ~/.codex/config.toml, set base_url to the gateway, and put your key in the environment variable named by env_key. The wire protocol must be Responses. Codex removed Chat Completions support in February 2026, and wire_api = "chat" now fails at startup, so most tutorials that still show wire_api = "chat" no longer work.
The config below works on current Codex CLI releases. Every error string in this guide is quoted from the Codex source or from a live response from the Wokey API.
Full config (copy and paste)
# ~/.codex/config.toml
model = "gpt-6-sol"
model_provider = "wokey"
[model_providers.wokey]
name = "Wokey"
base_url = "https://api.wokey.ai"
env_key = "WOKEY_API_KEY"
wire_api = "responses"
export WOKEY_API_KEY="your Wokey API key"
codex
What each field does:
| Field | Purpose | Common mistake |
|---|---|---|
model_provider |
Top-level key naming the [model_providers.<id>] table to use |
Leave it out and Codex stays on the built-in openai provider and asks you to sign in to ChatGPT |
base_url |
Gateway address; Codex appends /responses |
Don't add /responses yourself, or requests go to /responses/responses |
env_key |
The name of the environment variable holding the key; Codex sends it as Authorization: Bearer |
This is the variable name, not the key itself |
wire_api |
Wire protocol; "responses" is the only valid value and the default |
"chat" fails at startup |
On Wokey, base_url can be https://api.wokey.ai or https://api.wokey.ai/v1; the gateway serves both /responses and /v1/responses. For other gateways, follow their docs: many only register the /v1 paths.
The variable name is up to you. OPENAI_API_KEY works, but if you also use the official OpenAI API, a separate WOKEY_API_KEY keeps the two keys from overwriting each other.
Why older tutorials break
Timeline:
- 2025-12-09: the Codex team posted GitHub discussion #7782, "Deprecating chat/completions support in Codex". It announced removal in early February 2026, asked users with
wire_api = "chat"or nowire_apito migrate, and asked gateways to confirm Responses support. - 2026-02-03: PR #10157, "chore: nuke chat/completions API" was merged and the Chat Completions code was deleted.
Since then Codex's WireApi has a single value, Responses. With wire_api = "chat" still in the config, Codex fails at startup with:
`wire_api = "chat"` is no longer supported.
How to fix: set `wire_api = "responses"` in your provider config.
More info: https://github.com/openai/codex/discussions/7782
Change it to wire_api = "responses" or delete the line. It also means a gateway that only speaks Chat Completions can no longer serve Codex: check for a /v1/responses endpoint before you pick one.
Other settings that are outdated or ignored
api_key inside the provider table. Codex rejects unknown fields in provider config, so an api_key = "sk-..." line makes the config fail to parse. Pass the key through the variable named by env_key. If you really must put a token in the file, the field is experimental_bearer_token, though that isn't recommended.
[profiles.xxx] and a top-level profile = "xxx". Since Codex 0.134.0, --profile xxx overlays ~/.codex/xxx.config.toml. [profiles.xxx] tables in config.toml are no longer read, and top-level profile = is no longer supported. To switch between your official account and a gateway, put the Wokey provider in ~/.codex/wokey.config.toml and start with codex --profile wokey.
Providers in a project's .codex/config.toml. Project-level config ignores model_provider and model_providers. Providers can only be defined under your home ~/.codex/.
Provider id openai, ollama or lmstudio. These ids are reserved for built-in providers and can't define a custom one. Use another name, such as wokey.
Which model to use
Codex only sends Responses requests, so prefer models that serve /v1/responses natively. On Wokey that currently means the GPT family (gpt-6-sol, gpt-6-luna, gpt-6-astra, gpt-5.6-sol), the Grok family (grok-4.7, grok-4.6) and deepseek-flash. The "Supported endpoints" list on each model page is authoritative, and the lineup changes over time.
Models without native Responses, such as those listing only Chat Completions, still work from Codex on Wokey. The gateway converts the request to the upstream's protocol and converts the result back to Responses. The conversion is lossy, though:
- Some Codex-specific tools are dropped when converting to Chat Completions, such as the freeform
apply_patch,local_shelland the built-inweb_search. - Tool calls only appear once the whole reply is finished.
For your main coding model, pick one with native Responses.
Troubleshooting
Missing environment variable: `WOKEY_API_KEY`.
Codex didn't find the variable named by env_key. Check the spelling and make sure you exported it in the same terminal that starts codex. If you added it to ~/.zshrc or ~/.bashrc, open a new terminal.
HTTP 401 with {"error":{"code":"invalid_api_key","message":"invalid_api_key","type":"invalid_request_error"}}
Wokey returns this for a missing or wrong key. Check that the key was copied in full, hasn't been deleted in the console, and has no stray quotes or spaces in the variable.
HTTP 404 with Route POST:/responses/responses not found
base_url ends in /responses. Codex appends the path itself, so base_url should stop at the domain (or /v1).
Codex asks you to sign in to ChatGPT
There's no top-level model_provider = "wokey", or the provider sits in a project .codex/config.toml where it's ignored. Codex has fallen back to the built-in openai provider.
wire_api = "chat" is no longer supported
See above: change it to "responses" or delete the line.
HTTP 402 Your account balance has run out.
To rule Codex out, test the key and endpoint with curl first:
curl https://api.wokey.ai/v1/responses \
-H "Authorization: Bearer $WOKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6-sol","input":"ping"}'
If curl works and Codex doesn't, the problem is in config.toml. If curl fails too, the problem is the key or the network.
FAQ
Can Codex still use wire_api = "chat"?
No. Codex removed Chat Completions support in PR #10157, merged on 2026-02-03. wire_api now accepts only responses, and chat fails at startup. Change it to wire_api = "responses" or delete the line; it is the default.
Should the Codex base_url include /v1?
Codex appends /responses to base_url. With Wokey, https://api.wokey.ai and https://api.wokey.ai/v1 both work. Do not add /responses yourself, or you get a 404 Route POST:/responses/responses not found.
Can I put the API key directly in config.toml?
An api_key field in the provider table makes the config fail to parse, because Codex rejects unknown provider fields. Name an environment variable with env_key and export that variable instead.
Can Codex use Claude or other non-GPT models?
On Wokey, yes: the gateway converts the Responses request to the upstream protocol. The conversion drops some Codex-specific tools, so for coding pick a model with native /v1/responses, such as gpt-6-sol, grok-4.7 or deepseek-flash.
Why did my [profiles] config stop working?
Since Codex 0.134.0, --profile name overlays ~/.codex/name.config.toml, and [profiles.name] tables in config.toml are no longer read. Move that config into its own file.