npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-qwencode-auth

v1.3.0

Published

Qwen OAuth authentication plugin for OpenCode - Access Qwen AI models (Coder, Vision) with your qwen.ai account

Downloads

938

Readme

🤖 Qwen Code OAuth Plugin para OpenCode

npm version License GitHub stars

Autentique o OpenCode CLI com sua conta qwen.ai. Este plugin permite usar modelos Qwen (Coder, Max, Plus e mais) com 2.000 requisições gratuitas por dia - sem API key ou cartão de crédito!

🇺🇸 Read in English

✨ Funcionalidades

  • 🔐 OAuth Device Flow - Autenticação segura via navegador (RFC 8628)
  • Polling Automático - Não precisa pressionar Enter após autorizar
  • 🆓 2.000 req/dia grátis - Plano gratuito generoso sem cartão
  • 🧠 1M de contexto - Modelos com 1 milhão de tokens de contexto
  • 🔄 Auto-refresh - Tokens renovados automaticamente antes de expirar
  • 🔗 Compatível com qwen-code - Reutiliza credenciais de ~/.qwen/oauth_creds.json

📋 Pré-requisitos

🚀 Instalação

1. Instale o plugin

cd ~/.opencode && npm install opencode-qwencode-auth

2. Habilite o plugin

Edite ~/.opencode/opencode.jsonc:

{
  "plugin": ["opencode-qwencode-auth"]
}

🔑 Uso

1. Login

opencode auth login

2. Selecione o Provider

Escolha "Other" e digite qwen-code

3. Autentique

Selecione "Qwen Code (qwen.ai OAuth)"

  • Uma janela do navegador abrirá para você autorizar
  • O plugin detecta automaticamente quando você completa a autorização
  • Não precisa copiar/colar códigos ou pressionar Enter!

[!TIP] No TUI do OpenCode (interface gráfica), o provider Qwen Code aparece automaticamente na lista de providers.

🎯 Modelos Disponíveis

Modelos de Código

| Modelo | Contexto | Max Output | Melhor Para | |--------|----------|------------|-------------| | qwen3-coder-plus | 1M tokens | 64K tokens | Tarefas complexas de código | | qwen3-coder-flash | 1M tokens | 64K tokens | Respostas rápidas de código |

Modelos de Propósito Geral

| Modelo | Contexto | Max Output | Reasoning | Melhor Para | |--------|----------|------------|-----------|-------------| | qwen3-max | 256K tokens | 64K tokens | Não | Modelo flagship, raciocínio complexo e tool use | | qwen-plus-latest | 128K tokens | 16K tokens | Sim | Equilíbrio qualidade-velocidade com thinking mode | | qwen3-235b-a22b | 128K tokens | 32K tokens | Sim | Maior modelo open-weight MoE com thinking mode | | qwen-flash | 1M tokens | 8K tokens | Não | Ultra-rápido, baixo custo para tarefas simples |

Usando um modelo específico

opencode --provider qwen-code --model qwen3-coder-plus
opencode --provider qwen-code --model qwen3-max
opencode --provider qwen-code --model qwen-plus-latest

⚙️ Como Funciona

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   OpenCode CLI  │────▶│  qwen.ai OAuth   │────▶│  Qwen Models    │
│                 │◀────│  (Device Flow)   │◀────│  API            │
└─────────────────┘     └──────────────────┘     └─────────────────┘
  1. Device Flow (RFC 8628): Abre seu navegador em chat.qwen.ai para autenticação
  2. Polling Automático: Detecta a conclusão da autorização automaticamente
  3. Armazenamento de Token: Salva credenciais em ~/.qwen/oauth_creds.json
  4. Auto-refresh: Renova tokens 30 segundos antes de expirar

📊 Limites de Uso

| Plano | Rate Limit | Limite Diário | |-------|------------|---------------| | Gratuito (OAuth) | 60 req/min | 2.000 req/dia |

[!NOTE] Os limites resetam à meia-noite UTC. Para limites maiores, considere usar uma API key do DashScope.

🔧 Solução de Problemas

Token expirado

O plugin renova tokens automaticamente. Se houver problemas:

# Remova credenciais antigas
rm ~/.qwen/oauth_creds.json

# Re-autentique
opencode auth login

Provider não aparece no auth login

O provider qwen-code é adicionado via plugin. No comando opencode auth login:

  1. Selecione "Other"
  2. Digite qwen-code

Rate limit excedido (erros 429)

  • Aguarde até meia-noite UTC para reset da cota
  • Tente usar qwen3-coder-flash para requisições mais leves
  • Considere a API DashScope para limites maiores

🛠️ Desenvolvimento

# Clone o repositório
git clone https://github.com/gustavodiasdev/opencode-qwencode-auth.git
cd opencode-qwencode-auth

# Instale dependências
bun install

# Verifique tipos
bun run typecheck

Teste local

Edite ~/.opencode/package.json:

{
  "dependencies": {
    "opencode-qwencode-auth": "file:///caminho/absoluto/para/opencode-qwencode-auth"
  }
}

Depois reinstale:

cd ~/.opencode && npm install

📁 Estrutura do Projeto

src/
├── constants.ts        # Endpoints OAuth, config de modelos
├── types.ts            # Interfaces TypeScript
├── index.ts            # Entry point principal do plugin
├── qwen/
│   └── oauth.ts        # OAuth Device Flow + PKCE
└── plugin/
    ├── auth.ts         # Gerenciamento de credenciais
    └── utils.ts        # Utilitários

🔗 Projetos Relacionados

📄 Licença

MIT