Skip to main content

Qwen Provider

Access Qwen Code models (Qwen3 Coder) through OAuth authentication with Device Code flow. No API keys required - authenticate via browser and use instantly.

Overview

The Qwen provider enables Claude Code to use Qwen’s coding-specialized models through OAuth authentication. Uses Device Code flow for enhanced security. Provider Identifier: qwen Command: ccs qwen Supported Models:
  • Qwen3 Coder (optimized for code generation)
  • Additional models configurable via CLIProxy settings

Authentication

First-Time Setup

# Run Qwen for the first time
ccs qwen "optimize this function"

# Device Code flow starts automatically
# → Display device code + verification URL
# → User manually authorizes in browser
# → CLIProxyAPI polls for token completion
# → Token cached at ~/.ccs/cliproxy/auth/
# → Future runs require no re-auth
Device Code Flow:
  1. CCS displays device code and verification URL
  2. User opens URL in any browser
  3. Enter device code to authorize
  4. Token automatically cached when complete
  5. No callback server required (more secure)
Example Output:
Authenticate with Qwen:
1. Open https://qwen.ai/device
2. Enter code: ABCD-1234
3. Authorize CCS CLI access

Waiting for authorization...

Manual Authentication

# Authenticate without starting a session
ccs qwen --auth

# Headless mode (server/SSH environments)
# Device Code flow works naturally in headless - no special flag needed
ccs qwen --auth
# → Displays URL + code for manual browser authentication

Logout

# Clear all Qwen tokens
ccs qwen --logout

Multi-Account Support

Manage multiple Qwen accounts for different projects:

Add Account

# Add new account (preserves existing)
ccs qwen --auth --add

List Accounts

# Show all authenticated Qwen accounts
ccs qwen --accounts

# Output:
# Accounts for qwen:
#   [default] dev (dev@company.com)
#   testing (test@company.com)

Switch Account

# Switch to specific account by nickname
ccs qwen --use testing

# Next command uses testing's account
ccs qwen "your prompt"

Rename Account

# Rename default account nickname
ccs qwen --nickname primary
Account Registry: ~/.ccs/cliproxy/accounts.json Auto-Nicknames: Generated from email prefix (e.g., john@example.comjohn)

Configuration Options

Model Settings

Qwen provider settings stored in: Path: ~/.ccs/qwen.settings.json Configuration via Dashboard:
# Open web config interface
ccs config

# Navigate to CLIProxy → Qwen settings
Manual Configuration:
{
  "env": {
    "ANTHROPIC_MODEL": "qwen3-coder",
    "ANTHROPIC_MAX_TOKENS": "8192"
  }
}

CLIProxy Integration

Qwen integrates with unified CLIProxy config: Path: ~/.ccs/cliproxy/config.yaml Provider Routing: Requests routed to /api/provider/qwen endpoint Concurrent Usage: Run Qwen + other providers simultaneously without conflicts

Commands

Basic Usage

# Run with Qwen
ccs qwen "implement binary search algorithm"

# Interactive chat
ccs qwen

Authentication Flags

FlagDescription
--authTrigger OAuth flow (no session)
--logoutClear all tokens
--auth --addAdd new account (keep existing)

Account Management Flags

FlagDescription
--accountsList all accounts
--use <nickname>Switch default account
--nickname <name>Rename default account

Storage Locations

PathPurpose
~/.ccs/cliproxy/auth/qwen-*.jsonOAuth tokens (one per account)
~/.ccs/cliproxy/accounts.jsonAccount registry with nicknames
~/.ccs/qwen.settings.jsonProvider-specific settings
~/.ccs/cliproxy/config.yamlCLIProxy unified config

Token Management

Storage Format:
{
  "type": "qwen",
  "access_token": "...",
  "refresh_token": "...",
  "email": "user@example.com",
  "expired": "2024-12-31T23:59:59Z"
}
Auto-Refresh: Tokens managed by CLIProxyAPI Security: Device Code flow prevents token interception (no callback server)

Device Code Flow Details

Why Device Code?
  • More secure (no callback server listening on local port)
  • Works seamlessly in headless environments
  • No port conflicts or firewall issues
  • User completes auth on trusted device
Flow Timeline:
  1. CCS requests device code from Qwen API
  2. Displays code + URL to user
  3. User authorizes in browser (any device)
  4. CCS polls Qwen API for token availability
  5. Token saved when authorization complete
Callback Port: null (no server required)

Requirements

  • Qwen subscription
  • Browser for OAuth (on any device - not necessarily same machine)
  • Network access to Qwen authentication servers

Troubleshooting

Device Code Expired

Error: “Device code expired before authorization” Solution: Device codes expire after 10-15 minutes. Re-run ccs qwen --auth to get new code.

Authorization Not Detected

# Verify token file exists
ls ~/.ccs/cliproxy/auth/qwen-*.json

# Re-authenticate if missing
ccs qwen --logout
ccs qwen --auth

Multi-Account Issues

# List all accounts to verify state
ccs qwen --accounts

# Switch to specific account
ccs qwen --use <nickname>

Token Expiry

Tokens refresh automatically via CLIProxyAPI. If refresh fails:
# Re-authenticate
ccs qwen --auth

Cost Information

Qwen Subscription Required: Check qwen.ai for current pricing Usage Limits: Subject to Qwen’s rate limits and subscription tier

Next Steps