πŸ€– Qwen Code OAuth Plugin for OpenCode

April 4, 2026 Β· View on GitHub

npm version License GitHub stars

OpenCode with Qwen Code

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

ModelContextMax OutputFeatures
coder-model1M tokensUp to 64K tokensQwen 3.6 Plus β€” video & vision support

Note: This plugin aligns with the official qwen-code client. The coder-model alias 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:

  1. Re-authenticate: Run opencode auth login again.
  2. 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