Skip to main content

Overview

The --model (or -m) option allows you to specify which AI model Qwen Code should use for the session. Different models offer different capabilities, speeds, and costs.

Syntax

Available Models

Qwen Models (Dashscope)

Best for complex coding tasks
Specifications:
  • Context: 256K tokens
  • Quality: Highest
  • Speed: Medium
  • Cost: $$$
Use for:
  • Multi-file refactoring
  • Complex algorithms
  • Architecture decisions
  • Large codebase navigation

OpenAI Models

When using OpenAI authentication:

Anthropic Models

When using Anthropic authentication:

Basic Usage

Specify Model at Launch

With Other Options

Model Selection Strategy

For Development Tasks

For Different Project Sizes

Model Comparison

Configuration

Via Settings File

Set a default model:

Via Environment Variable

Project-Specific Defaults

Precedence Order

  1. Command-line --model flag (highest priority)
  2. Environment variable QWEN_MODEL
  3. Project settings .qwen/settings.json
  4. Global settings ~/.qwen/settings.json (lowest priority)

Advanced Usage

Switch Models Mid-Session

In interactive mode:

Model-Specific Prompts

Cost Optimization

Custom Models

OpenAI-Compatible APIs

Use custom or self-hosted models:

Configuration for Custom Models

Model Capabilities

Tool Support

All models support Qwen Code tools: ✅ File operations (read, write, edit)
✅ Shell commands
✅ Code search
✅ Git operations
✅ Web search

Feature Comparison

Real-World Examples

Web Development

Data Science

DevOps

Performance Tips

Match Model to Task

Use Fast Models for Iteration

Monitor Token Usage

Troubleshooting

Model Not Available

Solutions:
  1. Check authentication:
  2. Verify model name:
  3. Check API access:

Authentication Issues

Solution:

Invalid Model Name

Correct names:
  • qwen-coder-plus (not qwen-coder)
  • qwen-turbo (not qwen-fast)
  • qwen-max (not qwen-large)

Best Practices

Begin with fast models, upgrade as needed:
Set appropriate defaults per project:
Monitor costs and adjust:
Choose models with appropriate context:

See Also

/model Command

Switch models in interactive mode

Authentication

Set up model provider authentication

Model Comparison

Detailed model benchmarks and comparison

Configuration

Configure default models and settings