{"id":50961944,"url":"https://github.com/dvaji/opencode-qwencode-auth","last_synced_at":"2026-06-18T15:01:50.414Z","repository":{"id":349443731,"uuid":"1196419939","full_name":"dvaJi/opencode-qwencode-auth","owner":"dvaJi","description":"OpenCode plugin for Qwen Code OAuth authentication. Provides free access to Qwen Coder models through the official OAuth flow.","archived":false,"fork":false,"pushed_at":"2026-04-06T00:01:10.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-06T01:29:13.764Z","etag":null,"topics":["bun","opencode-plugin","qwen"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvaJi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-30T17:22:23.000Z","updated_at":"2026-04-06T00:01:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dvaJi/opencode-qwencode-auth","commit_stats":null,"previous_names":["dvaji/opencode-qwencode-auth"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/dvaJi/opencode-qwencode-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvaJi%2Fopencode-qwencode-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvaJi%2Fopencode-qwencode-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvaJi%2Fopencode-qwencode-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvaJi%2Fopencode-qwencode-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvaJi","download_url":"https://codeload.github.com/dvaJi/opencode-qwencode-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvaJi%2Fopencode-qwencode-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34495380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","opencode-plugin","qwen"],"created_at":"2026-06-18T15:01:46.526Z","updated_at":"2026-06-18T15:01:50.406Z","avatar_url":"https://github.com/dvaJi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @dvaji/opencode-qwen-auth\n\nOpenCode plugin for Qwen Code OAuth authentication. Provides free access to Qwen Coder models through the official OAuth flow.\n\n## Features\n\n- **OAuth Device Flow** - Secure authentication via browser\n- **Multi-Account Support** - Use multiple Qwen accounts for higher rate limits\n- **Smart Rotation** - Automatic account rotation with health-based selection\n- **Rate Limit Handling** - Automatic retry with exponential backoff\n- **Token Refresh** - Automatic token refresh before expiration\n\n## Installation\n\n### From npm (Recommended)\n\nAdd to your OpenCode config (`~/.config/opencode/opencode.json`):\n\n```json\n{\n  \"plugin\": [\"@dvaji/opencode-qwen-auth\"]\n}\n```\n\nOpenCode will automatically install and load the plugin at startup.\n\n### From Git Repository (Alternative)\n\n```json\n{\n  \"plugin\": [\"@dvaji/opencode-qwen-auth@git+https://github.com/dvaJi/opencode-qwencode-auth.git\"]\n}\n```\n\n### Manual Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/dvaJi/opencode-qwencode-auth.git\ncd opencode-qwencode-auth\n\n# Install dependencies\nbun install\n```\n\n## Limits \u0026 Quotas\n\n- **Rate Limit:** 60 requests per minute\n- **Daily Quota:** ~2000 requests per day (reset at midnight UTC)\n\n\u003e **Note:** These limits are set by the Qwen OAuth API and may change.\n\n## Authentication\n\nThe plugin uses Qwen OAuth (free tier). When you first use it with OpenCode, you'll be prompted to authenticate via browser.\n\n### Usage\n\n```bash\n# Authenticate\nopencode auth login\n\n# Use the model\nopencode --provider qwen-code --model coder-model\n```\n\n### Manual Authentication\n\nIf the automatic flow doesn't work (e.g., in containers), you can use the CLI helper:\n\n```bash\nbun run src/cli.ts\n```\n\n## Configuration\n\nConfiguration is stored in `~/.config/opencode/qwen-auth.json` (Linux/macOS) or `%APPDATA%/opencode/qwen-auth.json` (Windows).\n\n### Configuration Options\n\n```json\n{\n  \"rotation_strategy\": \"round-robin\",\n  \"proactive_refresh\": true,\n  \"refresh_window_seconds\": 300,\n  \"max_rate_limit_wait_seconds\": 300,\n  \"quiet_mode\": false,\n  \"pid_offset_enabled\": false,\n  \"health_score\": {\n    \"initial\": 70,\n    \"min_usable\": 50,\n    \"success_reward\": 1,\n    \"failure_penalty\": 20,\n    \"recovery_rate_per_hour\": 2\n  },\n  \"token_bucket\": {\n    \"max_tokens\": 50,\n    \"regeneration_rate_per_minute\": 6\n  }\n}\n```\n\n### Rotation Strategies\n\n| Strategy | Description |\n|----------|-------------|\n| `round-robin` | Simple sequential selection |\n| `sequential` | Use first available, skip rate-limited |\n| `hybrid` | Health score + token bucket + freshness (recommended) |\n\n### Configuration Options Detail\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `rotation_strategy` | `round-robin` | Account selection strategy |\n| `proactive_refresh` | `true` | Refresh tokens before expiration |\n| `refresh_window_seconds` | `300` | Seconds before expiry to refresh |\n| `max_rate_limit_wait_seconds` | `300` | Max wait time for rate-limited accounts |\n| `quiet_mode` | `false` | Disable debug logging |\n| `pid_offset_enabled` | `false` | Distribute accounts across processes |\n\n## Multi-Account Support\n\nQwen OAuth has ~2000 requests/day limit. To increase capacity, add multiple accounts:\n\n1. Authenticate with the first account through OpenCode\n2. The credentials are stored in `~/.config/opencode/qwen-accounts.json`\n3. Repeat authentication to add more accounts\n\nThe plugin will automatically distribute requests across accounts using the configured rotation strategy.\n\n## Troubleshooting\n\n### \"Invalid access token\" or \"Token expired\"\n\nThe plugin usually handles refresh automatically. If you see this error immediately:\n\n1. **Re-authenticate:** Run `opencode auth login` again.\n2. **Clear cache:** Delete the credentials file and login again:\n\n```bash\nrm ~/.config/opencode/qwen-accounts.json\nopencode auth login\n```\n\n### Rate limit exceeded (429 errors)\n\nIf you hit the rate limits:\n\n- **Rate limit (60/min):** Wait a few minutes before trying again\n- **Daily quota (~2000/day):** Wait until midnight UTC for the quota to reset\n\n### Enable Debug Logs\n\nIf something isn't working, you can see detailed logs:\n\n```bash\nOPENCODE_QWEN_DEBUG=1 opencode\n```\n\n## Development\n\n### Running Tests\n\n```bash\nbun test\n```\n\n### Project Structure\n\n```\nsrc/\n├── plugin/\n│   ├── account.ts      # Multi-account management\n│   ├── rotation.ts     # Health score \u0026 token bucket\n│   ├── config/        # Configuration loading\n│   └── request-queue.ts # Rate limiting\n├── qwen/\n│   └── oauth.ts       # OAuth device flow\n├── constants.ts       # Configuration constants\n├── errors.ts         # Error types\n└── plugin.ts         # Main plugin entry\n```\n\n## Credits\n\n- [Qwen Code](https://github.com/QwenLM/qwen-code) - Official OAuth implementation\n- [foxswat/opencode-qwen-auth](https://github.com/foxswat/opencode-qwen-auth) - Reference implementation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvaji%2Fopencode-qwencode-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvaji%2Fopencode-qwencode-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvaji%2Fopencode-qwencode-auth/lists"}