This guide will show you how to run Claude Code locally while using Qwen models for free, fully optimized for Windows 10/11 PowerShell.
You will install the required tools, extract your Qwen access token, configure Claude Code Router, and start coding with Qwen models inside Claude Code β all for free.
Make sure you have installed the following:
- Qwen CLI (already authenticated)
- Node.js v18+ (Download from: https://nodejs.org)
Open PowerShell and run:
npm install -g @qwen-code/qwen-code@latestThen install Claude Code + Router:
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-routerGo to:
C:\Users\YOUR_USERNAME\.qwen\oauth_creds.json
Example content:
{
"access_token": "YOUR_QWEN_ACCESS_TOKEN_HERE",
"token_type": "Bearer",
"refresh_token": "YOUR_REFRESH_TOKEN",
"resource_url": "portal.qwen.ai",
"expiry_date": 1764876220290
}π Copy the value of access_token This will be used in the Claude Code Router config.
Paste this into PowerShell:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude-code-router", "$env:USERPROFILE\.claude"This creates:
C:\Users\YourName\.claude-code-router
C:\Users\YourName\.claude
Run this entire block in PowerShell (it will auto-create config.json):
@"
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "qwen",
"api_base_url": "https://portal.qwen.ai/v1/chat/completions",
"api_key": "YOUR_QWEN_ACCESS_TOKEN_HERE",
"models": [
"qwen3-coder-plus",
"qwen3-coder-plus",
"qwen3-coder-plus"
]
}
],
"Router": {
"default": "qwen,qwen3-coder-plus",
"background": "qwen,qwen3-coder-plus",
"think": "qwen,qwen3-coder-plus",
"longContext": "qwen,qwen3-coder-plus",
"longContextThreshold": 60000,
"webSearch": "qwen,qwen3-coder-plus"
}
}
"@ | Out-File -FilePath "$env:USERPROFILE\.claude-code-router\config.json" -Encoding UTF8Now open the file:
notepad "$env:USERPROFILE\.claude-code-router\config.json"Replace:
YOUR_QWEN_ACCESS_TOKEN_HERE
with your real access token from Step 2.
Save and close.
Restart the router:
ccr restartStart Claude Code:
ccr codeTest it:
> hi
If it responds β congratulations! Youβre now using Claude Code with free Qwen models.
You may sometimes get:
401 Unauthorized
This means your Qwen OAuth token expired.
If the access_token in both files matches:
config.json
oauth_creds.json
Delete this file:
C:\Users\YourName\.qwen\oauth_creds.json
Or Run this command simply:
del "$env:USERPROFILE\.qwen\oauth_creds.json"
Then run:
qwen
This will prompt login again and generate a new token.
Open:
notepad "$env:USERPROFILE\.claude-code-router\config.json"Replace the old api_key with your new access_token.
ccr restartDone.
You now have the perfect setup to use Claude Code with Qwen (free) on Windows.