FAQ
Codex
The most common errors when the Codex CLI and extension connect to 2api, and how to fix them.
unexpected status 401 Unauthorized
Section titled “unexpected status 401 Unauthorized”First look at the address after url: at the end of the error.
If it is api.openai.com or chatgpt.com: your custom provider isn’t taking effect, and requests still go to the official service. Check each of these:
- Does
config.tomlhave the linemodel_provider = "sub2api", and does the name match[model_providers.sub2api]exactly (case-sensitive)? - Are these lines below a
[...]section? Lines placed under a section are read as settings of that section. Move them to the very start of the file. - Is the provider named
openai? That is a name built into Codex, and a custom address is ignored for it. Use another name. - Did you write the config in the project’s
.codex/config.toml? A provider can only be defined in~/.codex/config.toml. - Is there a leftover
OPENAI_BASE_URLin your environment variables?
If it is 2api.dev: the request reached 2api, so the problem is the key.
~/.codex/auth.jsonstill holds ChatGPT sign-in information. Back it up, delete it, and write the key again (see Codex CLI).- The key is wrong, or its group isn’t a GPT group.
- Run
codex login statusto see which sign-in method is in use.
After you change anything, fully quit Codex and start a new session.
stream disconnected before completion
Section titled “stream disconnected before completion”- Check that
base_urlishttps://2api.dev/v1. - A dead proxy is set in the terminal. Run
env | grep -i proxyto check. Fix the proxy, or addNO_PROXY=2api.dev. - The connection drops during long thinking: add
stream_idle_timeout_ms = 600000under[model_providers.sub2api]. - A tool such as CC Switch broke the config: write it again as described in Codex CLI.
- If it happens with any model at any time, contact support and include the time.
Every new conversation gets stuck on Reconnecting… 1/5 to 5/5
Section titled “Every new conversation gets stuck on Reconnecting… 1/5 to 5/5”Codex tries a WebSocket connection first. If your network or proxy doesn’t support it, it retries 5 times before falling back to a normal connection. Delete supports_websockets = true from config.toml, and responses_websockets_v2 = true under [features] (or set both to false). Then fully restart Codex.
Model not supported, or reasoning level not supported
Section titled “Model not supported, or reasoning level not supported”Model "xxx" is not supported by any configured account in this group: this group doesn’t have the model. Use the model name shown under Use Key (使用密钥) in the console, or look it up with/v1/models.Unsupported value: 'xxx' is not supported with the 'yyy' model: the model doesn’t support the reasoning level you set. Changemodel_reasoning_effort, or delete that line.- To try another model temporarily:
codex -m model-name -c model_reasoning_effort="high"
wire_api = “chat” is no longer supported
Section titled “wire_api = “chat” is no longer supported”New versions of Codex only support the Responses protocol. Change wire_api to "responses".
The VS Code extension says Missing environment variable, or keeps spinning
Section titled “The VS Code extension says Missing environment variable, or keeps spinning”GUI editors can’t see variables you export in a terminal. Write the key into auth.json (see Codex CLI) and don’t rely on environment variables. Then fully quit the editor and open it again. When the config file has a format error, the extension quietly falls back to default settings. Run codex once in a terminal to see the error with its line number.
Session history disappeared after changing base_url
Section titled “Session history disappeared after changing base_url”Session history is tied to the provider name. Keep model_provider = "sub2api", [model_providers.sub2api] and name = "sub2api" identical in all three places. Change only base_url and the key. Don’t rename the provider.
Does signing in to Codex again lose my sessions?
Section titled “Does signing in to Codex again lose my sessions?”No. As long as you don’t delete ~/.codex/sessions, resetting the sign-in or changing the config doesn’t delete your session history.
Only “exceeded retry limit, last status: 429” is shown
Section titled “Only “exceeded retry limit, last status: 429” is shown”Codex hides the real cause. Run the self-check command to see the full error, then compare it with the kinds of 429 errors.