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
- 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 - Step 2.
Enter /models and select the model you want.
Snippet/models - Step 3.
Verify.
Terminalopencode run "Hello" - 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 } } } } } } - 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" } - 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.
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 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.
- alibabacloud.comhttps://www.alibabacloud.com/help/en/model-studio/opencode
- opencode.aihttps://opencode.ai/docs/providers/
- 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.