Authenticate OpenCode CLI with your qwen.ai account. This plugin enables you to use Qwen3-Coder models with 2,000 free requests per day - no API key or credit card required!
- 🔐 OAuth Device Flow - Secure browser-based authentication (RFC 8628)
- ⚡ Automatic Polling - No need to press Enter after authorizing
- 🆓 2,000 req/day free - Generous free tier with no credit card
- 🧠 1M context window - Models with 1 million token context
- 🔄 Auto-refresh - Tokens renewed automatically before expiration
- 🔗 qwen-code compatible - Reuses credentials from
~/.qwen/oauth_creds.json
- OpenCode CLI installed
- A qwen.ai account (free to create)
cd ~/.opencode && npm install opencode-qwencode-authEdit ~/.opencode/opencode.jsonc:
{
"plugin": ["opencode-qwencode-auth"]
}opencode auth loginChoose "Other" and type qwen-code
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!
Tip
In the OpenCode TUI (graphical interface), the Qwen Code provider appears automatically in the provider list.
| Model | Context | Max Output | Best For |
|---|---|---|---|
qwen3-coder-plus |
1M tokens | 64K tokens | Complex coding tasks |
qwen3-coder-flash |
1M tokens | 64K tokens | Fast responses |
opencode --provider qwen-code --model qwen3-coder-plus┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ OpenCode CLI │────▶│ qwen.ai OAuth │────▶│ Qwen3-Coder │
│ │◀────│ (Device Flow) │◀────│ API │
└─────────────────┘ └──────────────────┘ └─────────────────┘
- Device Flow (RFC 8628): Opens your browser to
chat.qwen.aifor authentication - Automatic Polling: Detects authorization completion automatically
- Token Storage: Saves credentials to
~/.qwen/oauth_creds.json - Auto-refresh: Renews tokens 30 seconds before expiration
| Plan | Rate Limit | Daily Limit |
|---|---|---|
| Free (OAuth) | 60 req/min | 2,000 req/day |
Note
Limits reset at midnight UTC. For higher limits, consider using an API key from DashScope.
The plugin automatically renews tokens. If issues persist:
# Remove old credentials
rm ~/.qwen/oauth_creds.json
# Re-authenticate
opencode auth loginThe qwen-code provider is added via plugin. In the opencode auth login command:
- Select "Other"
- Type
qwen-code
- Wait until midnight UTC for quota reset
- Try using
qwen3-coder-flashfor faster, lighter requests - Consider DashScope API for higher limits
# Clone the repository
git clone https://github.com/gustavodiasdev/opencode-qwencode-auth.git
cd opencode-qwencode-auth
# Install dependencies
bun install
# Type check
bun run typecheckEdit ~/.opencode/package.json:
{
"dependencies": {
"opencode-qwencode-auth": "file:///absolute/path/to/opencode-qwencode-auth"
}
}Then reinstall:
cd ~/.opencode && npm installsrc/
├── constants.ts # OAuth endpoints, models config
├── types.ts # TypeScript interfaces
├── index.ts # Main plugin entry point
├── qwen/
│ └── oauth.ts # OAuth Device Flow + PKCE
└── plugin/
├── auth.ts # Credentials management
└── utils.ts # Helper utilities
- qwen-code - Official Qwen coding CLI
- OpenCode - AI-powered CLI for development
- opencode-gemini-auth - Similar plugin for Google Gemini
MIT
Made with ❤️ for the OpenCode community
