Docs · Guide

Qwen Code on any model

Qwen Code, the qwen coding agent from the Qwen team, takes models of your own in its settings. magpie adds its models there, so qwen can run on any model you have in magpie, not only Qwen: DeepSeek, Kimi, GLM, an OpenAI or Anthropic key, or a ChatGPT or Copilot subscription, with no key pasted into qwen.

Qwen Code keeps its settings in ~/.qwen/settings.json (under $QWEN_HOME if set). magpie appends one entry per model to modelProviders.openai there, each with the gateway’s address, the model’s id, its name as qwen’s /model shows it, and its context window. Then it points model at your pick. The gateway translates each request for the model’s provider, tool calls and reasoning included. A Qwen Code in WSL is set up the same way.

Connect Qwen Code

  1. Add providers in magpieIn the Providers tab, add an API key or sign in to a subscription.
  2. Pick a model on Qwen Code’s rowIn the Agents tab, choose a model under magpie.
  3. Start a new qwen sessionQwen Code reads a session’s model when it starts, so start a new session, or pick the model again with /model, where magpie’s models are listed too.
Terminal
magpie qwen deepseek/deepseek-v4-pro    # Qwen Code on DeepSeek
magpie qwen                             # what Qwen Code runs on now

The key and /auth

Every magpie entry takes its key from MAGPIE_QWEN_API_KEY, which magpie sets in the settings’ env object. The name is Qwen Code’s own, so a variable you exported in your shell or in ~/.qwen/.env is unlikely to shadow it. magpie also sets security.auth.selectedType to openai, so qwen starts without asking /auth.

Your own models

Your own modelProviders entries stay as they were, in front of magpie’s, so their ids don’t move, and they are listed on Qwen Code’s row beside magpie’s. When you pick a model of magpie’s, the model and auth type you had, with their address, are kept aside to be put back.

Switch back

Pick one of your own models on the row, take the row off magpie, or run magpie qwen default. magpie puts back the model and auth type you had before, and removes its entries and its key once no model of magpie’s is in use.

FAQ

Can Qwen Code run on models other than Qwen?

Yes. Any model you have in magpie is in qwen’s list: DeepSeek, Kimi, GLM, GPT, Claude and more.

Can Qwen Code use my ChatGPT subscription?

Yes. Sign in to ChatGPT in magpie and pick a GPT model under magpie on Qwen Code’s row. qwen sends its requests to magpie, which uses the subscription.

Why doesn’t a running session change model?

Qwen Code reads a session’s model when the session starts. Start a new one, or pick the model with /model.

Does it work with Qwen Code in WSL?

Yes. magpie sets up a Qwen Code in a WSL distro too.

More agents on the same models: Models in OpenCode, Models in Claude Code and Copilot CLI on any model. Something fails? See Fixing common errors, or ask on Discord.