Qwen Chat Integration
Claude Code Router supports routing through Qwen Chat (通义千问) via the qwen.aikit.club API. It uses JWT-based authentication where you paste a token copied from the chat.qwen.ai web application.
:::warning Consult provider Terms & Conditions
This integration authenticates against a third-party service using your own account. Before using it, review the provider's Terms & Conditions — access may be limited by subscription tier, region, or the provider's service terms, and using client credentials outside the client they were issued for may violate those terms. You use this functionality at your own risk; CCR provides it for interoperability only and does not guarantee continued access to any third-party service.
See DISCLAIMER.md for the project's interoperability statement. :::
How It Works
- The CCR server hosts an auth page at
http://localhost:3456/qwen/auth - The page offers a bookmarklet and a manual paste form for obtaining the JWT token
- Once submitted, the token is validated against Qwen's API and saved to
~/.claude-code-router/qwen_auth.json - Automatic token rotation — expired tokens are detected on the next request and you'll be prompted to refresh
- Qwen's trailing
<details>...</details>metadata block is stripped from responses automatically
Prerequisites
- Access to the Qwen Chat API via
qwen.aikit.club - A Qwen Chat account
Setup
1. Authenticate via Browser
The CCR server hosts an auth page at http://localhost:3456/qwen/auth. Open it in your browser:
http://localhost:3456/qwen/auth
The page offers two methods:
Option 1 — Bookmarklet (recommended):
- On the auth page, drag the "Get Qwen Token" button to your bookmarks bar
- Open chat.qwen.ai in another tab and sign in
- Click the bookmarklet on the Qwen page — it reads the token from localStorage and sends it back to the auth page automatically
Option 2 — Manual paste:
- Open chat.qwen.ai, sign in, and open DevTools (
F12) - In the Console tab, run:
copy(localStorage.getItem('token')) - Go back to the auth page and paste the token into the form
The token is validated against Qwen's API and saved to ~/.claude-code-router/qwen-auth.json.
The bookmarklet's redirect target is hardcoded into the JS because it runs in the Qwen page's context (with no knowledge of CCR's address). By default it points to http://127.0.0.1:3456. If your CCR server is on a different host or port, set the QWEN_AUTH_REDIRECT env var before starting the server, e.g. QWEN_AUTH_REDIRECT=http://192.168.1.10:8080 — the bookmarklet will then redirect to that address.
3. Configure Provider
Add the Qwen provider to your ~/.claude-code-router/config.json:
{
"Providers": [
{
"name": "qwen",
"baseUrl": "https://qwen.aikit.club/v1/chat/completions",
"apiKey": "oauth_dummy_key",
"models": ["qwen-max", "qwen-plus", "qwen-turbo"],
"transformer": {
"use": ["qwen-auth", "reasoning", "OpenAI"]
}
}
],
"Router": {
"default": "qwen,qwen-max"
}
}
The qwen-auth transformer handles:
- Adding the
Authorization: Bearerheader with your token - Stripping the
<details>...</details>metadata block from responses
The reasoning transformer captures and replays Qwen's reasoning content across multi-turn conversations, maintaining coherence.
The OpenAI transformer registers the /v1/chat/completions endpoint — Qwen uses standard Chat Completions format.
4. Restart
docker compose restart ccr
Model Reference
| Model | Description |
|---|---|
qwen-max | Flagship model, best quality |
qwen-plus | Balanced performance and cost |
qwen-turbo | Fast, cost-effective for simple tasks |
Troubleshooting
Invalid token: The JWT token may have expired. Re-run ccr qwen-auth and paste a fresh token from chat.qwen.ai.
Trailing metadata in responses: The <details>...</details> block should be stripped automatically. If you see it in raw responses, the qwen-auth transformer may not be active — check that it's in your provider's transformer.use array.