Qwen Code supports multiple AI model providers through a unified modelProviders configuration in settings.json.
Overview
Model providers are configured by authentication type (protocol), with each type supporting multiple models:
{
"modelProviders": {
"openai": [ /* OpenAI-compatible models */ ],
"anthropic": [ /* Anthropic Claude models */ ],
"gemini": [ /* Google Gemini models */ ],
"vertex-ai": [ /* Vertex AI models */ ]
}
}
Supported Providers
OpenAI-Compatible
The openai protocol supports any OpenAI-compatible API, including:
- Alibaba Cloud DashScope (Qwen models)
- OpenAI (GPT models)
- OpenRouter (multiple providers)
- ModelScope
- Custom OpenAI-compatible endpoints
Anthropic
Supports Claude models through the Anthropic API.
Google GenAI
Supports Gemini models through the Google Generative AI API.
Vertex AI
Supports models through Google Cloud Vertex AI.
Model Configuration Schema
Each model configuration has the following structure:
The model ID sent to the API (e.g., qwen3-coder-plus, gpt-4o, claude-sonnet-4-20250514).
Display name shown in the UI and model selector.
The name of the environment variable that holds your API key.Common values:
DASHSCOPE_API_KEY for Alibaba Cloud
OPENAI_API_KEY for OpenAI
ANTHROPIC_API_KEY for Anthropic
GEMINI_API_KEY for Google Gemini
The API endpoint URL. Required for non-default endpoints.Examples:
https://dashscope.aliyuncs.com/compatible-mode/v1 (DashScope)
https://api.openai.com/v1 (OpenAI)
https://coding.dashscope.aliyuncs.com/v1 (Bailian Coding Plan)
Optional description of the model shown in the UI.
Model-specific generation configuration.generationConfig.extra_body
Additional parameters passed to the API request body.Example for enabling thinking mode:{
"extra_body": {
"enable_thinking": true
}
}
Request timeout in milliseconds.
generationConfig.maxRetries
Maximum number of retries for failed requests.
Configuration Examples
Qwen Models (DashScope)
{
"modelProviders": {
"openai": [
{
"id": "qwen3-coder-plus",
"name": "Qwen3 Coder Plus",
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"description": "Qwen3-Coder via Dashscope",
"envKey": "DASHSCOPE_API_KEY"
}
]
},
"env": {
"DASHSCOPE_API_KEY": "sk-xxxxxxxxxxxxx"
},
"security": {
"auth": {
"selectedType": "openai"
}
},
"model": {
"name": "qwen3-coder-plus"
}
}
Alibaba Cloud Bailian Coding Plan
The Coding Plan provides fixed monthly pricing with higher quotas and access to multiple models:
{
"modelProviders": {
"openai": [
{
"id": "qwen3.5-plus",
"name": "qwen3.5-plus (Coding Plan)",
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"description": "qwen3.5-plus with thinking enabled from Bailian Coding Plan",
"envKey": "BAILIAN_CODING_PLAN_API_KEY",
"generationConfig": {
"extra_body": {
"enable_thinking": true
}
}
},
{
"id": "qwen3-coder-plus",
"name": "qwen3-coder-plus (Coding Plan)",
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"envKey": "BAILIAN_CODING_PLAN_API_KEY"
},
{
"id": "glm-4.7",
"name": "glm-4.7 (Coding Plan)",
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"envKey": "BAILIAN_CODING_PLAN_API_KEY",
"generationConfig": {
"extra_body": {
"enable_thinking": true
}
}
},
{
"id": "kimi-k2.5",
"name": "kimi-k2.5 (Coding Plan)",
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"envKey": "BAILIAN_CODING_PLAN_API_KEY",
"generationConfig": {
"extra_body": {
"enable_thinking": true
}
}
}
]
},
"env": {
"BAILIAN_CODING_PLAN_API_KEY": "sk-xxxxxxxxxxxxx"
},
"model": {
"name": "qwen3-coder-plus"
}
}
OpenAI Models
{
"modelProviders": {
"openai": [
{
"id": "gpt-4o",
"name": "GPT-4o",
"envKey": "OPENAI_API_KEY",
"baseUrl": "https://api.openai.com/v1"
},
{
"id": "gpt-4o-mini",
"name": "GPT-4o Mini",
"envKey": "OPENAI_API_KEY",
"baseUrl": "https://api.openai.com/v1"
}
]
},
"env": {
"OPENAI_API_KEY": "sk-xxxxxxxxxxxxx"
},
"security": {
"auth": {
"selectedType": "openai"
}
},
"model": {
"name": "gpt-4o"
}
}
Anthropic Claude
{
"modelProviders": {
"anthropic": [
{
"id": "claude-sonnet-4-20250514",
"name": "Claude Sonnet 4",
"envKey": "ANTHROPIC_API_KEY"
},
{
"id": "claude-opus-4-20250514",
"name": "Claude Opus 4",
"envKey": "ANTHROPIC_API_KEY"
}
]
},
"env": {
"ANTHROPIC_API_KEY": "sk-ant-xxxxxxxxxxxxx"
},
"security": {
"auth": {
"selectedType": "anthropic"
}
},
"model": {
"name": "claude-sonnet-4-20250514"
}
}
Google Gemini
{
"modelProviders": {
"gemini": [
{
"id": "gemini-2.5-pro",
"name": "Gemini 2.5 Pro",
"envKey": "GEMINI_API_KEY"
},
{
"id": "gemini-2.5-flash",
"name": "Gemini 2.5 Flash",
"envKey": "GEMINI_API_KEY"
}
]
},
"env": {
"GEMINI_API_KEY": "AIzaxxxxxxxxxxxxx"
},
"security": {
"auth": {
"selectedType": "gemini"
}
},
"model": {
"name": "gemini-2.5-pro"
}
}
Multiple Providers
You can configure multiple providers and switch between them using the /model command:
{
"modelProviders": {
"openai": [
{
"id": "qwen3-coder-plus",
"name": "Qwen3 Coder Plus",
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"envKey": "DASHSCOPE_API_KEY"
},
{
"id": "gpt-4o",
"name": "GPT-4o",
"envKey": "OPENAI_API_KEY",
"baseUrl": "https://api.openai.com/v1"
}
],
"anthropic": [
{
"id": "claude-sonnet-4-20250514",
"name": "Claude Sonnet 4",
"envKey": "ANTHROPIC_API_KEY"
}
],
"gemini": [
{
"id": "gemini-2.5-pro",
"name": "Gemini 2.5 Pro",
"envKey": "GEMINI_API_KEY"
}
]
},
"env": {
"DASHSCOPE_API_KEY": "sk-xxxxxxxxxxxxx",
"OPENAI_API_KEY": "sk-xxxxxxxxxxxxx",
"ANTHROPIC_API_KEY": "sk-ant-xxxxxxxxxxxxx",
"GEMINI_API_KEY": "AIzaxxxxxxxxxxxxx"
},
"security": {
"auth": {
"selectedType": "openai"
}
},
"model": {
"name": "qwen3-coder-plus"
}
}
Switching Models
Once configured, you can switch models in several ways:
Using the /model Command
In an interactive session:
qwen
# In the session:
/model
# Choose from configured models
Using the --model Flag
Setting Default in Settings
{
"model": {
"name": "qwen3-coder-plus"
}
}
Authentication Type
The security.auth.selectedType determines which API protocol to use:
{
"security": {
"auth": {
"selectedType": "openai" // or "anthropic", "gemini", "vertex-ai", "qwen-oauth"
}
}
}
Available Auth Types
openai - OpenAI-compatible APIs (DashScope, OpenAI, OpenRouter, etc.)
anthropic - Anthropic Claude API
gemini - Google Generative AI
vertex-ai - Google Cloud Vertex AI
qwen-oauth - Qwen OAuth (free tier, no API key needed)
Environment Variables
API keys can be provided in three ways (in order of priority):
-
System/Shell environment variables (highest priority)
export DASHSCOPE_API_KEY=sk-xxxxxxxxxxxxx
-
.env files (see Environment Variables)
-
settings.json → env field (lowest priority)
{
"env": {
"DASHSCOPE_API_KEY": "sk-xxxxxxxxxxxxx"
}
}
Never commit API keys to version control. Use .env files or system environment variables for sensitive credentials.
Best Practices
-
Store API keys securely: Use
.env files or system environment variables instead of committing them to settings.json.
-
Use descriptive names: Give your models clear, distinguishable names to make switching easier.
-
Set a default model: Configure
model.name to set your preferred default.
-
Organize by use case: You can configure the same model multiple times with different settings (e.g., with/without thinking mode).
-
Document custom endpoints: Use the
description field to note what each model configuration is for.
Troubleshooting
”Missing API key” Error
Ensure your API key environment variable is set:
# Check if the variable is set
echo $DASHSCOPE_API_KEY
# Set it if needed
export DASHSCOPE_API_KEY=sk-xxxxxxxxxxxxx
Model Not Available
Verify:
- The model
id matches what the provider expects
- The
baseUrl is correct for your provider
- The
envKey matches your environment variable name
- The
security.auth.selectedType matches the provider protocol
Rate Limiting
Configure retry and timeout settings:
{
"model": {
"generationConfig": {
"timeout": 120000,
"maxRetries": 3
}
}
}
See Also