Docs · Provider

Qwen in Claude Code, Codex, Gemini CLI and OpenCode

Alibaba serves Qwen through DashScope, on Alibaba Cloud Model Studio, Bailian and Qwen Cloud, pay as you go or on a Token Plan. Every one of them speaks OpenAI Chat Completions and Anthropic Messages. Add your key to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Qwen through magpie’s gateway at 127.0.0.1:3425.

Add Qwen

  1. Get a keyPay as you go: Model Studio (international) or Bailian (China). A Token Plan’s key comes from its own plan page.
  2. Add the providerIn magpie’s Providers tab, press + Add provider, pick the Qwen preset your key is from (the table below), paste the key and save. magpie asks the endpoint which models it serves.
  3. Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose a Qwen model such as qwen3.8-max.
Terminal
magpie provider add qwen sk-…                     # Model Studio, international
magpie provider add qwen-cn sk-…                  # Bailian, China
magpie provider add bailian-token-plan sk-sp-…    # Bailian Token Plan
magpie provider add qwencloud sk-ws-… region=us-east-1
Each key works on its own host only. A Token Plan key (sk-sp-…) is refused by pay-as-you-go endpoints and by the other Token Plans, and a Qwen Cloud key is refused outside its region. If a request comes back 401, check that the key sits under the preset it was made for.

Plans and endpoints

PresetPlan and keyEndpoints (Chat Completions, Anthropic Messages)
Qwen qwenpay as you go, international (Model Studio)https://dashscope-intl.aliyuncs.com/compatible-mode/v1
https://dashscope-intl.aliyuncs.com/apps/anthropic
Qwen (China) qwen-cnpay as you go, China (Bailian)https://dashscope.aliyuncs.com/compatible-mode/v1
https://dashscope.aliyuncs.com/apps/anthropic
Qwen Token Plan qwen-token-plansubscription, sk-sp-https://token-plan.maas.qianwenaiapi.com/compatible-mode/v1
https://token-plan.maas.qianwenaiapi.com/apps/anthropic
Bailian Token Plan bailian-token-plansubscription, sk-sp-https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1
https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
Qwen Cloud qwencloudpay as you go, sk-ws-, six regions, Singapore the defaulthttps://{region}.maas.qwencloudapi.com/compatible-mode/v1
https://{region}.maas.qwencloudapi.com/apps/anthropic
Qwen Cloud Token Plan qwencloud-token-plansubscription, sk-sp-, Singaporehttps://token-plan.maas.qwencloudapi.com/compatible-mode/v1
https://token-plan.maas.qwencloudapi.com/apps/anthropic

When a Token Plan’s host gives no model list, magpie offers the plan’s text models as its overview lists them: auto, qwen3.8-max, qwen3.8-flash, qwen3.7-max, qwen3.7-plus, qwen3.6-flash, and the DeepSeek and GLM models the plan includes. The Bailian Token Plan also serves a decision model that can classify turns for intent routing.

In each agent

Pick the model on an agent’s row in the Agents tab, or from a terminal. Each guide says what magpie writes in that agent’s config and how to switch back.

Terminal
magpie claude qwen/qwen3.8-max
magpie codex qwen/qwen3.8-max
magpie gemini model qwen/qwen3.7-plus
magpie opencode qwen/qwen3.8-max

Qwen Code is one of the agents magpie connects too: its row takes Qwen’s models or any other vendor’s.

Thinking and images

Balance and usage

magpie shows no balance or plan card for Qwen: DashScope has no API for a key’s balance, and neither Token Plan has one for its credits, which the plan’s subscription page in Alibaba’s console shows. The Usage tab counts tokens, cache hits and cost for each agent and model that went through magpie.

FAQ

How do I use Qwen in Claude Code?

Add your key in magpie (Providers, Add provider, then the Qwen preset your key is from), then pick a Qwen model such as qwen3.8-max on Claude Code’s row, or run magpie claude qwen/qwen3.8-max. magpie writes Claude Code’s settings.json and passes its requests to DashScope’s Anthropic endpoint.

Can Codex use Qwen, Qwen3 Coder included?

Yes. magpie lists the models DashScope gives your key, coder models included, and Codex can use any of them: magpie translates Codex’s Responses requests to Chat Completions and the replies back. Pick the model on Codex’s row or run magpie codex qwen/qwen3.8-max; it shows in Codex’s /model list.

Which preset do I pick for my key?

The one whose site the key is from. A Token Plan key (sk-sp-…) works only on its own plan’s host, and a Qwen Cloud pay-as-you-go key (sk-ws-…) only in its own region, so a key added to another preset is turned away with 401.

Can Qwen Code use other models?

Yes. Qwen Code is one of the agents magpie connects, so its row in the Agents tab takes any model you have added, Qwen’s or another vendor’s.

Why does a Qwen request without streaming work in magpie?

DashScope turns away a thinking Qwen model asked for one whole reply (enable_thinking must be false for non-streaming calls). magpie asks for it streamed and hands the agent the whole reply, thinking included.

Does magpie show my Token Plan credits?

No. Neither Token Plan has an API for its credits; the plan’s subscription page in Alibaba’s console shows them. magpie’s Usage tab still counts the tokens each agent spent.

Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.