Qwen Code 是阿里巴巴 Qwen 团队开源的 coding agent。它核心是交互式 CLI,同时支持 headless mode、VS Code、Zed、JetBrains 等 IDE integrations,以及基于其构建的 desktop app。它原生支持 OpenAI、Anthropic 和 Gemini protocols,因此可以直接连接到 siflow OpenAI-compatible endpoint。
以下配置适用于 Qwen Code 的所有形态。
通过 npm 安装 Qwen Code 需要 Node.js 22 或更高版本。如果安装后版本异常或 Qwen Code 无法启动,请先检查 node --version;使用低于 22 的 Node 安装可能会拉取 incomplete build。
1. 安装 Qwen Code
先检查 Node 版本:
如果版本低于 22,请升级 Node。官方下载页面 覆盖各平台和安装方式。
使用 nvm 时,请设置 default alias。否则新终端可能回退到旧 Node 版本,导致 npm 安装的命令从 PATH 中消失。
安装 Qwen Code:
2. 使用环境变量配置
在 API 密钥 页面创建 API Key,然后将连接设置写入 Qwen Code 的 env file。该文件会在每次启动、每个终端中自动加载。
普通 export 命令也可使用,但只在当前 shell session 中有效。Qwen Code 会依次搜索 .qwen/.env、从当前目录向上查找的 .env、~/.qwen/.env、~/.env。项目级 .qwen/.env 可以让不同项目使用不同 key。
首次启动时,在 /auth dialog 中选择 provider。当前 UI 提供 Alibaba ModelStudio、Third-party Providers 和 Custom Provider。连接算秩请选择 Custom Provider。
3. 使用 settings.json 配置
如需持久配置,请先创建 config 目录,然后编辑 ~/.qwen/settings.json:
将 key 存入 Qwen Code 的 env file:
普通 export SIFLOW_API_KEY="..." 也可使用,但只在当前 shell session 中有效。新终端会丢失它,Qwen Code 会显示 “Missing credentials … Set that environment variable”。
设置 security.auth.selectedType 后,Qwen Code 会直接进入已配置 provider,不再弹出 /auth dialog。
model.name 必须与 modelProviders 下的某个 id 完全一致。否则该模型不会出现在 /model 中。
glm-5.2 是推荐默认模型。如果需要更快响应,也可以选择支持原生 tool calling 的 DeepSeek-V4-Flash。
如果不想 export,也可以在 settings.json 中使用顶层 "env": { "SIFLOW_API_KEY": "..." } block。它优先级最低;shell exports 和 .env files 会覆盖它。项目级 .qwen/settings.json 会覆盖 home 目录中的配置。
在交互模式中发送任务,例如 “list the current directory and summarize the project structure”,并确认 tool calls 和回复正常。
也可以 headless 验证:
VS Code Companion
Qwen Code 有官方 VS Code extension:Qwen Code Companion(qwenlm.qwen-code-vscode-ide-companion)。在 Qwen Code 中运行 /ide install 即可设置,也可以从 marketplace 安装后运行 /ide enable。
它会把 workspace context(例如 recent files、cursor position、selection)提供给 agent,并显示 native diff review。Zed 和 JetBrains integrations 也可用,参考 官方 IDE integration docs。