Skip to main content
Watch: Anthropic Just Hit the Brakes on Its Next AI Model

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

  1. Step 1.

    Open or create ~/.codex/config.toml (Windows: C:\Users\<username>\.codex\config.toml).

  2. 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.

    TOML
    model_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"
  3. 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.

    TOML
    npm 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"
  4. Step 4.

    Token Plan (Personal or Team Edition, Responses API): replace OPENAI_API_KEY with your Token Plan API key.

    TOML
    model_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"
  5. Step 5.

    Pay-as-you-go Chat Completions configuration (Codex 0.93.0 or earlier, or a model that supports only Chat Completions).

    TOML
    model_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"
  6. Step 6.

    Verify: run the following in your project directory.

    Terminal
    codex exec "Hello"

Caveats

  • Codex 0.94.0 and later no longer support wire_api = "chat" and fail with wire_api = "chat" is no longer supported or unknown 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 Unauthorized means the key belongs to another plan, the subscription expired, or the key was copied incorrectly; unexpected status 404 Not Found means 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.

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.

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.