Codex can call the generally available qwen4-max model through QwenCloud Token Plan's Responses-compatible endpoint. Configure a Token Plan-specific API key, then verify connectivity with a read-only smoke test command.
Suitable tasks: Using QwenCloud Token Plan's Qwen4-Max for coding and inference in Codex CLI
Unsuitable tasks: Using an API key for pay-as-you-go billing or another plan; keys are not interchangeable across plans
Applicable model version: qwen4-max; do not use qwen4-max-preview
Applicable client, agent, or API: Codex CLI, QwenCloud Token Plan Responses API
Recommended reasoning level and parameters: reasoning_effort=high and thinking_budget=131072 by default; consider xhigh for complex tasks, subject to the levels available in Codex
Add the following to ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml):
model_provider = "Token_Plan"
model = "qwen4-max"
[model_providers.Token_Plan]
name = "Token_Plan"
base_url = "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"The initial model value in the official Quick Start is auto. This configuration specifies qwen4-max, which is listed in the official model catalog, to pin usage to this model. You can also configure the model catalog as described in the official instructions, then switch models with codex -m qwen4-max. If model metadata is not configured, Codex may report that metadata was not found; the official documentation says this does not prevent calls to the model specified in config.toml.
Securely set the Token Plan Personal API key as an environment variable. Do not put the real key in a configuration file, repository, or command history:
read -s OPENAI_API_KEY
export OPENAI_API_KEYRun a read-only smoke test from a directory that contains no sensitive project files:
cd /tmp
codex exec --sandbox read-only -m qwen4-max "只回复 OK;不要调用工具或访问文件。"QwenCloud's official verification example is codex exec "Hello". The command above adapts it by explicitly specifying the model and adding --sandbox read-only to restrict local command execution. This is a safety adaptation, not a command copied verbatim from QwenCloud's documentation. It sends one model request, so first create or view a Personal API key in the corresponding Token Plan.
| Configuration item | Value |
|---|---|
| Plan | Token Plan Personal |
| Base URL | https://token-plan.maas.qwencloudapi.com/compatible-mode/v1 |
| API protocol | Responses (wire_api = "responses") |
| API key environment variable | OPENAI_API_KEY |
| Model ID | qwen4-max |
| Context window | 1,000,000 tokens |
| Maximum output | 131,072 tokens in non-thinking mode; 262,144 tokens for thinking and the final answer combined |
Create or view an API key on the QwenCloud Token Plan Personal page.
Securely set the key as OPENAI_API_KEY and add the Codex configuration above.
Run the read-only smoke test from /tmp; receiving OK indicates that the basic request succeeded. Do not use a Token Plan key with a pay-as-you-go endpoint.
The Quick Start on the official Codex page specifies the Token_Plan provider, Token Plan base URL, OPENAI_API_KEY, and wire_api = "responses", and verifies the setup with codex exec "Hello".
The model catalog on the same page lists the generally available qwen4-max model, the default reasoning level high, support for low / high / xhigh, and a 1,000,000-token context window. The preview model is listed separately as qwen4-max-preview.
The page states that Qwen4-Max uses thinking_budget=131072 by default, with a maximum output of 131,072 tokens in non-thinking mode and up to 262,144 tokens for thinking and the final answer combined.
The official FAQ says API keys for Token Plan Personal, Team, and pay-as-you-go are not interchangeable. Codex 0.94.0 and later no longer support wire_api = "chat".
This configuration applies only to QwenCloud Token Plan Personal. Team requires a key assigned to the team; pay-as-you-go requires that plan's own configuration and key.
The generally available model is qwen4-max. The preview model qwen4-max-preview and its dedicated metadata are not covered by this configuration.
The configuration and smoke test command are for Codex CLI. If your Codex version reports wire_api as an unknown field, follow the official FAQ and remove that field. If it reports that wire_api = "chat" is unsupported, confirm that the configuration uses responses.
The smoke test uses a read-only sandbox but still sends the prompt to the cloud and consumes plan quota. No request was made with a real key for this article.
On 2026-11-17, the QwenCloud official Codex documentation was opened and checked using the CLI installed in Tabbit. The configuration fields, endpoint, environment variable, and model metadata come from the page. Local codex exec --help was used to confirm that the --sandbox read-only option is available. No real API key was configured or used, and no online smoke test was run.
Qwen4-Max