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

Setup guide - Documented by Qwen

Use Qwen in OpenCode

Model Studio's OpenCode guide connects through OpenCode's /connect providers (Alibaba (China) for pay-as-you-go, Alibaba Coding Plan (China), Alibaba Token Plan (China)) or a custom provider in ~/.config/opencode/opencode.json that uses the @ai-sdk/anthropic package against Model Studio's Anthropic-compatible endpoint (/apps/anthropic/v1), with Qwen models declared in the models map.

Last verified 6 steps3 official sources

Steps

  1. Step 1.

    Run opencode, enter /connect, select the provider for your billing plan, and enter the API key: Alibaba (China) with a Model Studio API key, Alibaba Coding Plan (China) with a Coding Plan API key, or Alibaba Token Plan (China) with a Token Plan API key.

    Snippet
    /connect
  2. Step 2.

    Enter /models and select the model you want.

    Snippet
    /models
  3. Step 3.

    Verify.

    Terminal
    opencode run "Hello"
  4. Step 4.

    Config file alternative: open or create ~/.config/opencode/opencode.json (Windows: C:\Users\<username>\.config\opencode\opencode.json). Pay-as-you-go example (replace YOUR_API_KEY and {WorkspaceId}; the Alibaba example also lists deepseek-v4-pro-0813 and deepseek-v4.1-flash):

    JSON
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "bailian-payg": {
          "npm": "@ai-sdk/anthropic",
          "name": "Alibaba Cloud Model Studio",
          "options": {
            "baseURL": "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1",
            "apiKey": "YOUR_API_KEY"
          },
          "models": {
            "qwen3.8-max": {
              "name": "Qwen3.8 Max",
              "modalities": {
                "input": ["text", "image"],
                "output": ["text"]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen3.7-plus": {
              "name": "Qwen3.7 Plus",
              "modalities": {
                "input": ["text", "image"],
                "output": ["text"]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.8-flash": {
              "name": "Qwen3.8 Flash",
              "modalities": {
                "input": ["text", "image"],
                "output": ["text"]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            }
          }
        }
      }
    }
  5. Step 5.

    Coding Plan alternative: provider id bailian-coding-plan with the baseURL below and the Coding Plan key; the Alibaba page lists qwen3.7-plus, qwen3.6-plus, kimi-k2.5, glm-5, MiniMax-M2.5 and qwen3.5-plus.

    JSON
    "options": {
      "baseURL": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",
      "apiKey": "YOUR_API_KEY"
    }
  6. Step 6.

    Token Plan alternative: provider id bailian-token-plan with the baseURL below and the Token Plan key; models include auto, qwen3.8-max, qwen3.8-flash, qwen3.7-max, qwen3.7-plus, qwen3.6-flash (the Team Edition example adds qwen3.6-plus).

    JSON
    "options": {
      "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1",
      "apiKey": "YOUR_API_KEY"
    }

Caveats

  • OpenCode's current providers docs (opencode.ai/docs/providers) define custom providers under "providers" with "package", "settings" (baseURL) and "env" fields, while the Alibaba example uses the "provider" / "npm" / "options" shape. Both pages document the /connect then /models route, so prefer it if OpenCode rejects the config file.
  • The config-file examples store the API key inline in opencode.json.
  • Note the /v1 suffix on the Anthropic base URL for OpenCode, unlike Claude Code's /apps/anthropic.
  • If a model is missing, the Alibaba FAQ says to upgrade OpenCode to the latest version and check /models again, or define a custom provider in opencode.json.
  • 401 Unauthorized means the key does not match the selected provider or belongs to another billing plan; run /connect again with the correct key. Replace {WorkspaceId} in the pay-as-you-go baseURL.

FAQ

How do I use Qwen in OpenCode?

Model Studio's OpenCode guide connects through OpenCode's /connect providers (Alibaba (China) for pay-as-you-go, Alibaba Coding Plan (China), Alibaba Token Plan (China)) or a custom provider in ~/.config/opencode/opencode.json that uses the @ai-sdk/anthropic package against Model Studio's Anthropic-compatible endpoint (/apps/anthropic/v1), with Qwen models declared in the models map.

Which Qwen model ids work in OpenCode?

The official docs read for this guide list qwen3.8-max, qwen3.7-plus, qwen3.8-flash, qwen3.6-plus, qwen3.5-plus, qwen3.7-max, qwen3.6-flash and auto. Requests go to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1.

Is this an official Qwen and OpenCode setup?

Qwen documents this setup in its own docs. It was last checked against 3 official pages on November 8, 2026.

Sources

Last verified against 3 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.