π€ Qwen Code OAuth Plugin for OpenCode
April 4, 2026 Β· View on GitHub
Authenticate OpenCode CLI with your qwen.ai account. This plugin enables you to use the coder-model with 1,000 free requests per day β powered by Qwen 3.6 Plus with video and vision support. No API key or credit card required!
π§π· Leia em PortuguΓͺs | π Changelog
β¨ Features
- π OAuth Device Flow - Secure browser-based authentication (RFC 8628)
- π 1,000 req/day free - Free quota reset daily at midnight UTC
- β‘ 60 req/min - Rate limit of 60 requests per minute
- π§ 1M context window - Massive context support for large projects
- π Auto-refresh - Tokens renewed automatically before expiration
- β±οΈ Reliability - Built-in request throttling and automatic retry for transient errors
- π qwen-code compatible - Reuses credentials from
~/.qwen/oauth_creds.json
π Installation
Edit ~/.config/opencode/opencode.json:
{
"plugin": ["opencode-qwencode-auth"]
}
That's it! OpenCode will automatically install the plugin at startup.
Alternative installation methods
From npm (explicit version)
{
"plugin": ["opencode-qwencode-auth@latest"]
}
From Git repository
{
"plugin": ["opencode-qwencode-auth@git+https://github.com/gustavodiasdev/opencode-qwencode-auth.git#main"]
}
Specific version
{
"plugin": ["opencode-qwencode-auth@1.3.0"]
}
β οΈ Limits & Quotas
- Rate Limit: 60 requests per minute
- Daily Quota: 1,000 requests per day (reset at midnight UTC)
- Web Search: 200 requests/minute, 1,000/day (separate quota)
Note: These limits are set by the Qwen OAuth API and may change. For professional use with higher quotas, consider using a DashScope API Key.
π Usage
1. Login
Run the following command to start the OAuth flow:
opencode auth login
2. Select Provider
Choose "Other" and type qwen-code.
3. Authenticate
Select "Qwen Code (qwen.ai OAuth)".
- A browser window will open for you to authorize.
- The plugin automatically detects when you complete authorization.
- No need to copy/paste codes or press Enter!
π― Available Models
Coding Model
| Model | Context | Max Output | Features |
|---|---|---|---|
coder-model | 1M tokens | Up to 64K tokens | Qwen 3.6 Plus β video & vision support |
Note: This plugin aligns with the official
qwen-codeclient. Thecoder-modelalias maps to Qwen 3.6 Plus with hybrid reasoning, vision, and video input capabilities.
Using the model
opencode --provider qwen-code --model coder-model
π§ Troubleshooting
"Invalid access token" or "Token expired"
The plugin usually handles refresh automatically. If you see this error immediately:
- Re-authenticate: Run
opencode auth loginagain. - Clear cache: Delete the credentials file and login again:
rm ~/.qwen/oauth_creds.json opencode auth login
Rate limit exceeded (429 errors)
If you hit the 60 req/min or 1,000 req/day limits:
- Rate limit (60/min): Wait a few minutes before trying again
- Daily quota (1,000/day): Wait until midnight UTC for the quota to reset
- Web Search (200/min, 1,000/day): Separate quota for web search tool
- Consider using a DashScope API Key for professional use with higher quotas
Enable Debug Logs
If something isn't working, you can see detailed logs by setting the debug environment variable:
OPENCODE_QWEN_DEBUG=1 opencode
π οΈ Development
# Clone the repository
git clone https://github.com/gustavodiasdev/opencode-qwencode-auth.git
cd opencode-qwencode-auth
# Install dependencies
bun install
# Run tests
bun run tests/debug.ts full
Project Structure
src/
βββ qwen/ # OAuth implementation
βββ plugin/ # Token management & caching
βββ utils/ # Retry, locking and logging utilities
βββ constants.ts # Models and endpoints
βββ index.ts # Plugin entry point
π License
MIT
Made with β€οΈ for the OpenCode community