Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Setup guide - Documented by Qwen

Use Qwen in OpenCode

Model Studio's OpenCode guide adds a custom provider to ~/.config/opencode/opencode.json using 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 5 steps2 official sources

Steps

  1. Step 1.

    Install OpenCode (Node.js 18.0 or later) and verify.

    Terminal
    npm install -g opencode-ai
    opencode -v
  2. Step 2.

    Open (or create) ~/.config/opencode/opencode.json (Windows: C:\Users\<Your-Username>\.config\opencode\opencode.json). Pay-as-you-go config: replace YOUR_API_KEY and {WorkspaceId}. Region baseURLs: Beijing https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1, Singapore https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1, US (Virginia) https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/apps/anthropic/v1.

    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.7-max": {
              "name": "Qwen3.7 Max",
              "options": {
                "thinking": {
                  "type": "enabled",
                  "budgetTokens": 8192
                }
              }
            },
            "qwen3.7-plus": {
              "name": "Qwen3.7 Plus",
              "modalities": {
                "input": ["text", "image"],
                "output": ["text"]
              },
              "options": {
                "thinking": {
                  "type": "enabled",
                  "budgetTokens": 8192
                }
              }
            },
            "qwen3.6-plus": {
              "name": "Qwen3.6 Plus",
              "modalities": {
                "input": ["text", "image"],
                "output": ["text"]
              },
              "options": {
                "thinking": {
                  "type": "enabled",
                  "budgetTokens": 8192
                }
              }
            }
          }
        }
      }
    }
  3. Step 3.

    Coding Plan alternative: use provider id bailian-coding-plan with baseURL https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1 and the Coding Plan key; the Alibaba page lists qwen3.7-plus, qwen3.6-plus, qwen3.5-plus, MiniMax-M2.5, glm-5 and kimi-k2.5 (thinking budgetTokens 1024).

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

    Token Plan alternative: baseURL https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1 with the Token Plan key; models include auto, qwen3.8-max, qwen3.8-flash, qwen3.7-max, qwen3.7-plus, qwen3.6-flash.

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

    Verify: restart OpenCode, enter /models, search for Alibaba Cloud Model Studio, then select a model.

    Snippet
    /models

Caveats

  • The API key is stored inline in opencode.json in the Alibaba example; no environment variable is documented.
  • Note the /v1 suffix on the Anthropic base URL for OpenCode, unlike Claude Code's /apps/anthropic.
  • Replace {WorkspaceId}; the key must match the region.
  • Plan keys (Coding Plan sk-sp-..., Token Plan) and the general pay-as-you-go key are not interchangeable.

FAQ

How do I use Qwen in OpenCode?

Model Studio's OpenCode guide adds a custom provider to ~/.config/opencode/opencode.json using 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.7-max, qwen3.7-plus, qwen3.6-plus, qwen3.5-plus, qwen3.8-max, qwen3.8-flash and qwen3.6-flash. 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 2 official pages on October 17, 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.