Setup guide - Documented by Qwen
Use Qwen in Codex CLI
Model Studio documents Codex setup through a custom model_provider in ~/.codex/config.toml pointing at the OpenAI-compatible endpoint, with env_key = "OPENAI_API_KEY". Pay-as-you-go and Token Plan use wire_api = "responses"; the Coding Plan uses Chat Completions (wire_api = "chat") and requires Codex 0.93.0 or earlier, because Codex 0.94.0 and later support only the Responses API.
Last verified 6 steps2 official sources
Steps
- Step 1.
Open or create ~/.codex/config.toml (Windows: C:\Users\<username>\.codex\config.toml).
- Step 2.
Pay-as-you-go (Responses API): replace OPENAI_API_KEY with your Model Studio API key and {WorkspaceId} with your Workspace ID. The example uses Singapore.
TOMLmodel_provider = "Model_Studio" model = "qwen3.7-max" [model_providers.Model_Studio] name = "Model_Studio" base_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1" env_key = "OPENAI_API_KEY" wire_api = "responses" - Step 3.
Coding Plan (Chat Completions, Codex 0.93.0 or earlier): install the pinned Codex and replace OPENAI_API_KEY with your Coding Plan API key.
TOMLnpm install -g @openai/[email protected] model_provider = "Coding_Plan" model = "qwen3.7-plus" [model_providers.Coding_Plan] name = "Coding_Plan" base_url = "https://coding-intl.dashscope.aliyuncs.com/v1" env_key = "OPENAI_API_KEY" wire_api = "chat" - Step 4.
Token Plan (Personal or Team Edition, Responses API): replace OPENAI_API_KEY with your Token Plan API key.
TOMLmodel_provider = "Token_Plan" model = "auto" [model_providers.Token_Plan] name = "Token_Plan" base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1" env_key = "OPENAI_API_KEY" wire_api = "responses" - Step 5.
Pay-as-you-go Chat Completions configuration (Codex 0.93.0 or earlier, or a model that supports only Chat Completions).
TOMLmodel_provider = "Model_Studio" model = "qwen3.8-max" [model_providers.Model_Studio] name = "Model_Studio" base_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1" env_key = "OPENAI_API_KEY" wire_api = "chat" - Step 6.
Verify: run the following in your project directory.
Terminalcodex exec "Hello"
Caveats
- Codex 0.94.0 and later no longer support wire_api = "chat" and fail with
wire_api = "chat" is no longer supportedorunknown configuration field wire_api; to keep using Chat Completions (required by the Coding Plan), install Codex 0.93.0 or earlier (such as 0.80.0). unexpected status 401 Unauthorizedmeans the key belongs to another plan, the subscription expired, or the key was copied incorrectly;unexpected status 404 Not Foundmeans base_url or wire_api is wrong.- Third-party switchers such as CC-Switch may report "domestic models not supported" because their health-check probe is rejected with 400; Alibaba says this does not affect actual Codex use.
- Replace {WorkspaceId} with your Workspace ID; Token Plan, Coding Plan and pay-as-you-go keys are not interchangeable.
More setup guides
Same tool, other providers
Related reading
- Qwen4-Max: Pricing, Benchmarks and What to TestQwen4-Max is live on QwenCloud at $1.50 input and $4.50 output per million tokens, down from $2 and $6 for Qwen3.8-Max. What is vendor-reported, what is missing, and a test plan.
- GVS5H: Can Qwen3.8-27B Match Fable 5 on Coding?GVS5H claims five Qwen3.8-27B instances match Fable 5 on LiveCodeBench Hard. What the harness does, why Hacker News doubts the benchmark, and what to copy.
- Run Qwen3.8-Flash-Next on a Gaming PC With StrataRun Qwen3.8-Flash-Next locally with Strata on a 12 GB GPU: hardware needs, speeds by quant, the license catch, and when the hosted API is the better call.
- Terminal-Universe Turns Agent Traces Into Training EnvironmentsTerminal-Universe, Qwen's paper on rebuilding terminal-agent trajectories into reusable environments, and why agent teams should keep replayable workspaces.
- Qwen3.8-27B vs Opus 4.6 Max: Local Agentic Coding BenchmarksQwen3.8-27B is a 27B dense Apache-2.0 model that beats Opus 4.6 Max on SWE-bench Pro (61.7 vs 53.4). Benchmarks, hardware, cost and when to run it.
- Qwen 3.8 Max Ships: 2.4T MoE, 1M Context, $2/$6 per MTok, Open Weights Next WeekQwen 3.8 Max is a 2.4T-parameter MoE with 95B active, a 1M context window and $2/$6 per million tokens on QwenCloud, with open weights promised next week.
FAQ
How do I use Qwen in Codex CLI?
Model Studio documents Codex setup through a custom model_provider in ~/.codex/config.toml pointing at the OpenAI-compatible endpoint, with env_key = "OPENAI_API_KEY". Pay-as-you-go and Token Plan use wire_api = "responses"; the Coding Plan uses Chat Completions (wire_api = "chat") and requires Codex 0.93.0 or earlier, because Codex 0.94.0 and later support only the Responses API.
Which Qwen model ids work in Codex CLI?
The official docs read for this guide list qwen3.7-max, qwen3.8-max, qwen3.7-plus and auto. Requests go to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1.
Is this an official Qwen and Codex CLI setup?
Qwen documents this setup in its own docs. It was last checked against 2 official pages on November 8, 2026.
Sources
Last verified against 2 official pages.
- alibabacloud.comhttps://www.alibabacloud.com/help/en/model-studio/codex
- alibabacloud.comhttps://www.alibabacloud.com/help/en/model-studio/coding-plan
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.