OpenAI's terminal AI coding assistant
Codex is a terminal AI coding assistant developed by OpenAI. Connect it to QwenCloud via Token Plan (Personal Edition), Token Plan (Team Edition), or pay-as-you-go billing.
Run the following command to verify the installation.
To connect, edit the configuration file
For
Set the
Choose an access method based on the API the model supports:
If the selected model supports the OpenAI Responses API, you can use the latest Codex version.
Then configure model metadata so you can switch between models. Create
Add the following to
After configuring, switch between models with
Other models require the Chat/Completions API. Install an older version of Codex, such as 0.80.0 (newer Codex versions no longer support
For
Set the
Choose an access method based on the API the model supports:
If the selected model supports the OpenAI Responses API, you can use the latest Codex version.
Then configure model metadata so you can switch between models. Create
Add the following to
After configuring, switch between models with
Other models require the Chat/Completions API. Install an older version of Codex, such as 0.80.0 (newer Codex versions no longer support
Set the
Set the
Choose an access method based on the API the model supports:
Applicable to models that support the OpenAI Responses API (such as qwen3.7-max), compatible with the latest Codex version.
Then configure model metadata so you can switch between models. Create
Add the following to
After configuring, switch between models with
Applicable to models that only support the Chat/Completions API. Requires installing Codex 0.80.0:
After the configuration is complete, open a new terminal window and run the following command to start Codex:
If the chat interface launches successfully, the configuration is correct.
Cause: Some third-party management tools (such as CC-Switch) send a "health check / connection test" probe request when switching providers. The format of this probe differs from the request format Codex actually uses, so the QwenCloud gateway may reject it with 400 Bad request, and the tool then reports "domestic models not supported". This message only indicates that the health check probe failed; it does not mean QwenCloud lacks support for domestic models, nor does it affect actual Codex usage.
Note: QwenCloud supports using domestic models such as qwen3.7-max, qwen3.7-plus, qwen3.6-plus, qwen3.6-flash, and glm-5 through Codex. For configuration details, see Configure access credentials above.
Solution: Configure Codex directly in
Cause: Newer versions of Codex no longer support
Cause:
Cause: The
Cause: The streaming connection between Codex and the server was interrupted before the response completed. This commonly occurs in the following scenarios:
Cause: A 429 error occurs in two situations:
Install Codex
- Install or update Node.js (v18.0 or later).
- Run the following command in a terminal to install Codex.
Configure access credentials
To connect, edit the configuration file ~/.codex/config.toml and configure the environment variable OPENAI_API_KEY. Replace the corresponding values based on your selected billing plan.
Token Plan (Personal Edition)
For model, select a supported model. Set the OPENAI_API_KEY environment variable to the Token Plan (Personal Edition) dedicated API Key.
Step 1: Configure environment variables
Set the OPENAI_API_KEY environment variable to the Token Plan (Personal Edition) dedicated API Key.
- macOS
- Windows
- Run the following command in a terminal to check the default shell type.
- Set the environment variable based on your shell type:
- Zsh
- Bash
- Run the following command to apply the environment variable.
- Zsh
- Bash
Step 2: Choose an access method
Choose an access method based on the API the model supports:
Responses API
If the selected model supports the OpenAI Responses API, you can use the latest Codex version.
~/.codex/model-catalog.local.json with the models supported by this plan:
~/.codex/config.toml to point to the file:
codex -m (for example, codex -m qwen3.8-flash), or enter /model in the TUI.
Chat/Completions API (other models)
Other models require the Chat/Completions API. Install an older version of Codex, such as 0.80.0 (newer Codex versions no longer support wire_api = "chat"; if you get an error after upgrading, see the FAQ below):
qwen3.8-max thinking mode:
- thinking: Supports both enabled and disabled (hybrid thinking mode).
- temperature: Defaults to 0.6 in thinking mode. Values below 0.6 are automatically adjusted to 0.6.
- reasoning_effort: Controls reasoning depth. Options: xhigh, medium, low. Default: xhigh.
Token Plan (Team Edition)
For model, select a supported model. Set the OPENAI_API_KEY environment variable to the Token Plan (Team Edition) dedicated API Key.
Step 1: Configure environment variables
Set the OPENAI_API_KEY environment variable to the Token Plan (Team Edition) dedicated API Key.
- macOS
- Windows
- Run the following command in a terminal to check the default shell type.
- Set the environment variable based on your shell type:
- Zsh
- Bash
- Run the following command to apply the environment variable.
- Zsh
- Bash
Step 2: Choose an access method
Choose an access method based on the API the model supports:
Responses API
If the selected model supports the OpenAI Responses API, you can use the latest Codex version.
~/.codex/model-catalog.local.json with the models supported by this plan:
~/.codex/config.toml to point to the file:
codex -m (for example, codex -m qwen3.8-flash), or enter /model in the TUI.
Chat/Completions API (other models)
Other models require the Chat/Completions API. Install an older version of Codex, such as 0.80.0 (newer Codex versions no longer support wire_api = "chat"; if you get an error after upgrading, see the FAQ below):
qwen3.8-max thinking mode:
- thinking: Supports both enabled and disabled (hybrid thinking mode).
- temperature: Defaults to 0.6 in thinking mode. Values below 0.6 are automatically adjusted to 0.6.
- reasoning_effort: Controls reasoning depth. Options: xhigh, medium, low. Default: xhigh.
Pay-as-you-go
Set the OPENAI_API_KEY environment variable to your QwenCloud API Key and choose from the supported models.
Set base_url to https://maas.qwencloudapi.com/compatible-mode/v1.
Pay-as-you-go supports both the Responses API and the Chat/Completions API. Choose based on the model you are using:
Step 1: Configure environment variables
Set the OPENAI_API_KEY environment variable to your QwenCloud API Key.
- macOS
- Windows
- Run the following command in a terminal to check the default shell type.
- Set the environment variable based on your shell type:
- Zsh
- Bash
- Run the following command to apply the environment variable.
- Zsh
- Bash
Step 2: Choose an access method
Choose an access method based on the API the model supports:
Responses API
Applicable to models that support the OpenAI Responses API (such as qwen3.7-max), compatible with the latest Codex version.
~/.codex/model-catalog.local.json with the models supported by this plan:
~/.codex/config.toml to point to the file:
codex -m (for example, codex -m qwen3.8-max), or enter /model in the TUI.
Chat/Completions API
Applicable to models that only support the Chat/Completions API. Requires installing Codex 0.80.0:
Verify configuration
After the configuration is complete, open a new terminal window and run the following command to start Codex:
FAQ
What should I do if a third-party tool reports "domestic models not supported" or "check rejected / Bad request (400)"?
Cause: Some third-party management tools (such as CC-Switch) send a "health check / connection test" probe request when switching providers. The format of this probe differs from the request format Codex actually uses, so the QwenCloud gateway may reject it with 400 Bad request, and the tool then reports "domestic models not supported". This message only indicates that the health check probe failed; it does not mean QwenCloud lacks support for domestic models, nor does it affect actual Codex usage.
Note: QwenCloud supports using domestic models such as qwen3.7-max, qwen3.7-plus, qwen3.6-plus, qwen3.6-flash, and glm-5 through Codex. For configuration details, see Configure access credentials above.
Solution: Configure Codex directly in ~/.codex/config.toml as described in Configure access credentials, without relying on the third-party tool's health check result. After configuration, start Codex as described in Verify configuration; if the chat interface launches normally, domestic models are working.
What should I do if I get a wire_api configuration error?
Cause: Newer versions of Codex no longer support wire_api = "chat". Depending on the version, you may see one of the following errors:
wire_api = "chat" is no longer supportedunknown configuration field wire_api
- Error
wire_api = "chat" is no longer supported: Changewire_apitoresponsesand verify thatbase_urlis correct. See Configure access credentials for configuration examples. - Error
unknown configuration field wire_api: Remove thewire_apiline from the corresponding provider section in~/.codex/config.toml.
What should I do if I get the error "unexpected status 401 Unauthorized"?
Cause:
- Using an API Key from a different plan (API Keys for Token Plan (Personal Edition), Token Plan (Team Edition), and pay-as-you-go are not interchangeable)
- Subscription expired
- API Key was copied incompletely, contains spaces, or has a typo
- Verify that you are using the dedicated API Key for your selected plan.
- Go to the management page of your selected plan and check whether the subscription has expired.
- Re-copy the API Key and make sure it is complete and has no spaces.
- If the error persists after verifying the above, reset the API Key on the management page of your selected plan. After resetting, use the new API Key for configuration.
What should I do if I get the error "unexpected status 404 Not Found"?
Cause: The base_url or wire_api in the configuration file is incorrect.
Solution: Verify that base_url and wire_api match the configuration for your selected plan. See the configuration examples for your plan in Configure access credentials above.
What should I do if I get the error "stream disconnected before completion: stream closed before response.completed"?
Cause: The streaming connection between Codex and the server was interrupted before the response completed. This commonly occurs in the following scenarios:
- The conversation thread is too long, causing a context compaction request to fail
- Unstable network causing the SSE or WebSocket connection to drop mid-stream
- Server overload or rate limiting that terminates the connection early
- Start a new conversation thread to avoid excessive context accumulation in a single thread.
- Check your network connection. Try disabling VPN or proxy and retry.
- Wait and retry. Codex has a built-in retry mechanism that resolves most transient failures automatically.
What should I do if I get a 429 error for rate limiting or quota exhaustion?
Cause: A 429 error occurs in two situations:
- Rate limit exceeded (
429 Requests rate limit exceeded): Requests are too frequent within a short period. - Quota exhausted (
429 Allocated quota exceededorYour token-plan 1-week quota has been exhausted): The weekly or monthly limit of Token Plan has been reached.
- Rate limit exceeded: Wait one minute and retry with a reduced request frequency.
- Quota exhausted: Wait for the corresponding window period (weekly or monthly) to end, after which the quota resets automatically; or purchase a Credit Pack (Credit Pack Credits are not subject to window limits); or upgrade your plan. Note that the reset time in the error message (for example,
The quota will reset at HH:MM:SS UTC) is in Coordinated Universal Time (UTC).