11# opencode-qwen-auth
22
3- Plugin de autenticação OAuth para [ OpenCode CLI] ( https://opencode.ai ) que permite usar modelos Qwen3-Coder através da sua conta [ qwen.ai] ( https://chat.qwen.ai ) com ** 2. 000 requisições gratuitas por dia ** .
3+ OAuth authentication plugin for [ OpenCode CLI] ( https://opencode.ai ) that enables Qwen3-Coder models through your [ qwen.ai] ( https://chat.qwen.ai ) account with ** 2, 000 free requests per day ** .
44
5- ## Funcionalidades
5+ [ Leia em Português ] ( ./README.pt-BR.md )
66
7- - ** OAuth Device Flow** - Autenticação segura via navegador (RFC 8628)
8- - ** Polling Automático** - Detecta automaticamente quando você autoriza no navegador
9- - ** 2.000 req/dia grátis** - Sem necessidade de cartão de crédito
10- - ** 1M de contexto** - Modelos com janela de contexto de 1 milhão de tokens
11- - ** Auto-refresh** - Renova tokens automaticamente quando expiram
12- - ** Compatível com qwen-code** - Reutiliza credenciais existentes de ` ~/.qwen/oauth_creds.json `
7+ ## Features
138
14- ## Instalação
9+ - ** OAuth Device Flow** - Secure browser-based authentication (RFC 8628)
10+ - ** Automatic Polling** - Automatically detects when you authorize in the browser
11+ - ** 2,000 req/day free** - No credit card required
12+ - ** 1M context window** - Models with 1 million token context windows
13+ - ** Auto-refresh** - Automatically renews tokens when they expire
14+ - ** qwen-code compatible** - Reuses existing credentials from ` ~/.qwen/oauth_creds.json `
1515
16- ### 1. Adicione o plugin ao OpenCode
16+ ## Installation
1717
18- Edite ` ~/.opencode/package.json ` :
18+ ### 1. Add the plugin to OpenCode
19+
20+ Edit ` ~/.opencode/package.json ` :
1921
2022``` json
2123{
@@ -25,137 +27,137 @@ Edite `~/.opencode/package.json`:
2527}
2628```
2729
28- Edite ` ~/.opencode/opencode.jsonc ` :
30+ Edit ` ~/.opencode/opencode.jsonc ` :
2931
3032``` json
3133{
3234 "plugin" : [" opencode-qwen-auth" ]
3335}
3436```
3537
36- ### 2. Instale as dependências
38+ ### 2. Install dependencies
3739
3840``` bash
3941cd ~ /.opencode && npm install
4042```
4143
42- ### 3. Autentique
44+ ### 3. Authenticate
4345
44- Inicie o OpenCode e selecione o provider ** Qwen Code** :
46+ Start OpenCode and select the ** Qwen Code** provider :
4547
4648``` bash
4749opencode
4850```
4951
50- Ou via linha de comando (selecione "Other" e digite ` qwen-code ` ):
52+ Or via command line (select "Other" and type ` qwen-code ` ):
5153
5254``` bash
5355opencode auth login
5456```
5557
56- Escolha ** "Qwen Code (qwen.ai OAuth)"** e autorize no navegador .
58+ Choose ** "Qwen Code (qwen.ai OAuth)"** and authorize in your browser .
5759
58- ### 4. Use os modelos Qwen
60+ ### 4. Use Qwen models
5961
6062``` bash
6163opencode --provider qwen-code --model qwen3-coder-plus
6264```
6365
64- ## Modelos Disponíveis
66+ ## Available Models
6567
66- | Modelo | Contexto | Output | Descrição |
67- | -------- | ---------- | --------| -----------|
68- | ` qwen3-coder-plus ` | 1M tokens | 64K tokens | Modelo mais capaz para programação |
69- | ` qwen3-coder-flash ` | 1M tokens | 64K tokens | Respostas mais rápidas |
68+ | Model | Context | Output | Description |
69+ | -------| ---------| --------| -- -----------|
70+ | ` qwen3-coder-plus ` | 1M tokens | 64K tokens | Most capable coding model |
71+ | ` qwen3-coder-flash ` | 1M tokens | 64K tokens | Faster responses |
7072
71- ## Como Funciona
73+ ## How It Works
7274
73- 1 . ** Device Flow (RFC 8628)** : Ao fazer login, o plugin abre seu navegador para ` chat.qwen.ai `
74- 2 . ** Polling Automático ** : O plugin detecta automaticamente quando você autoriza (sem precisar pressionar Enter)
75- 3 . ** Armazenamento ** : Credenciais são salvas em ` ~/.qwen/oauth_creds.json ` (compatível com qwen-code)
76- 4 . ** Auto-refresh** : Tokens são renovados automaticamente 30 segundos antes de expirar
75+ 1 . ** Device Flow (RFC 8628)** : When logging in, the plugin opens your browser to ` chat.qwen.ai `
76+ 2 . ** Automatic Polling ** : The plugin automatically detects when you authorize (no need to press Enter)
77+ 3 . ** Storage ** : Credentials are saved to ` ~/.qwen/oauth_creds.json ` (compatible with qwen-code)
78+ 4 . ** Auto-refresh** : Tokens are automatically renewed 30 seconds before expiration
7779
78- ## Limites de Uso
80+ ## Usage Limits
7981
80- | Plano | Rate Limit | Limite Diário |
81- | ------- | ------------| -- -------------|
82- | Gratuito (OAuth) | 60 req/min | 2. 000 req/dia |
82+ | Plan | Rate Limit | Daily Limit |
83+ | ------| ------------| -------------|
84+ | Free (OAuth) | 60 req/min | 2, 000 req/day |
8385
84- ## Desenvolvimento Local
86+ ## Local Development
8587
8688``` bash
87- # Clone o repositório
89+ # Clone the repository
8890git clone https://github.com/gustavodiasdev/opencode-qwen-auth.git
8991cd opencode-qwen-auth
9092
91- # Instale dependências
93+ # Install dependencies
9294bun install
9395
94- # Verifique tipos
96+ # Type check
9597bun run typecheck
9698
97- # Link local no OpenCode
98- # Edite ~/.opencode/package.json:
99+ # Local link in OpenCode
100+ # Edit ~/.opencode/package.json:
99101{
100102 " dependencies" : {
101- " opencode-qwen-auth" : " file:/caminho/absoluto/para /opencode-qwen-auth"
103+ " opencode-qwen-auth" : " file:/absolute/path/to /opencode-qwen-auth"
102104 }
103105}
104106
105- # Reinstale
107+ # Reinstall
106108cd ~ /.opencode && npm install
107109```
108110
109- ## Estrutura do Projeto
111+ ## Project Structure
110112
111113```
112114src/
113- ├── constants.ts # Constantes (endpoints OAuth, modelos )
114- ├── types.ts # Interfaces TypeScript
115- ├── index.ts # Plugin principal
116- ├── cli.ts # CLI standalone (opcional )
115+ ├── constants.ts # Constants ( OAuth endpoints, models )
116+ ├── types.ts # TypeScript interfaces
117+ ├── index.ts # Main plugin
118+ ├── cli.ts # Standalone CLI (optional )
117119├── qwen/
118- │ └── oauth.ts # Lógica OAuth Device Flow + PKCE
120+ │ └── oauth.ts # OAuth Device Flow + PKCE logic
119121└── plugin/
120- ├── auth.ts # Gerenciamento de credenciais
121- ├── client.ts # Cliente API Qwen
122- └── utils.ts # Utilitários
122+ ├── auth.ts # Credentials management
123+ ├── client.ts # Qwen API client
124+ └── utils.ts # Utilities
123125```
124126
125127## Troubleshooting
126128
127- ### Token expirado
129+ ### Token expired
128130
129- O plugin renova tokens automaticamente. Se houver problemas :
131+ The plugin automatically renews tokens. If issues persist :
130132
131133``` bash
132- # Remova credenciais antigas
134+ # Remove old credentials
133135rm ~ /.qwen/oauth_creds.json
134136
135- # Re-autentique
137+ # Re-authenticate
136138opencode auth login
137139```
138140
139- ### Provider não aparece no ` auth login `
141+ ### Provider not showing in ` auth login `
140142
141- O provider ` qwen-code ` é adicionado via plugin. No comando ` opencode auth login ` :
142- 1 . Selecione ** "Other"**
143- 2 . Digite ` qwen-code `
143+ The ` qwen-code ` provider is added via plugin. In the ` opencode auth login ` command :
144+ 1 . Select ** "Other"**
145+ 2 . Type ` qwen-code `
144146
145- No TUI (interface gráfica do OpenCode ), o provider aparece automaticamente .
147+ In the TUI (OpenCode graphical interface ), the provider appears automatically .
146148
147- ### Rate limit excedido
149+ ### Rate limit exceeded
148150
149- Se atingir o limite diário (2. 000 requisições ):
150- - Aguarde até meia-noite UTC para reset
151- - Considere usar API Key do [ DashScope] ( https://dashscope.aliyun.com ) para limites maiores
151+ If you hit the daily limit (2, 000 requests ):
152+ - Wait until midnight UTC for quota reset
153+ - Consider using an API Key from [ DashScope] ( https://dashscope.aliyun.com ) for higher limits
152154
153- ## Projetos Relacionados
155+ ## Related Projects
154156
155- - [ qwen-code] ( https://github.com/QwenLM/qwen-code ) - CLI oficial do Qwen para programação
156- - [ OpenCode] ( https://opencode.ai ) - CLI de IA para desenvolvimento
157- - [ opencode-gemini-auth] ( https://github.com/jenslys/opencode-gemini-auth ) - Plugin similar para Google Gemini
157+ - [ qwen-code] ( https://github.com/QwenLM/qwen-code ) - Official Qwen coding CLI
158+ - [ OpenCode] ( https://opencode.ai ) - AI CLI for development
159+ - [ opencode-gemini-auth] ( https://github.com/jenslys/opencode-gemini-auth ) - Similar plugin for Google Gemini
158160
159- ## Licença
161+ ## License
160162
161163MIT
0 commit comments