Local OpenCode plugin for qwen.ai OAuth, with the same persistent credential cache style as qwen-code and opencode-qwen-auth, but without the legacy built-in Qwen providers/models.
This plugin builds on the newer Qwen Code direction and refresh work, adapted for OpenCode as a dedicated plugin-based integration.
It was also created because older OpenCode Qwen auth plugins like 1579364808/opencode-qwen-auth and gustavodiasdev/opencode-qwencode-auth no longer work.
This plugin was built after reviewing the main public Qwen/OpenCode auth implementations and forks, not just a single upstream:
QwenLM/qwen-code: primary upstream reference for OAuth flow, credential persistence, and refresh behaviorfoxswat/opencode-qwen-auth: strongest reference for resilience improvements and OpenCode integration ideasRunMintOn/OpenCode-Qwen-Proxy: useful reference for throttling and burst-handling behavior1579364808/opencode-qwen-auth: reviewed as an older baselinegustavodiasdev/opencode-qwencode-auth: reviewed as another older OpenCode-oriented implementation
The current design intentionally follows the strongest parts of those implementations while keeping the plugin small, current, and focused on the official free Qwen OAuth path.
- Everything in this project must be written in English.
- login provider:
openqwencode - model path:
openqwencode/coder-model - only the official free OAuth model:
coder-model - image input through the same
coder-model - tokens stored in qwen-code-compatible format in
~/.qwen/oauth_creds.json - automatic refresh so you do not have to log in again every day
- atomic writes + lockfile so multiple processes do not corrupt credentials
- in-memory cache with periodic disk sync
- backoff for
429and temporary server errors - cancellable auth polling, including process-signal cancellation
- removes/overrides legacy
qwenandqwen-codeproviders
{
"$schema": "https://opencode.ai/config.json",
"disabled_providers": ["qwen", "qwen-code"],
"plugin": ["file:///ABSOLUTE/PATH/TO/openqwencode"]
}Login:
opencode auth login -p openqwencodeThen use:
opencode --model openqwencode/coder-modelInstall the package:
npm install openqwencodeAdd it to your OpenCode config:
{
"$schema": "https://opencode.ai/config.json",
"disabled_providers": ["qwen", "qwen-code"],
"plugin": ["openqwencode"]
}Authenticate:
opencode auth login -p openqwencodeRun OpenCode with the plugin model:
opencode --model openqwencode/coder-modelLink this install to your telemetry dashboard connection:
npx openqwencode linkKeep these unset unless you explicitly want the behavior.
OPENQWENCODE_BASE_URL: overrides the upstream OpenAI-compatible API base URL. If set to a bare origin such ashttps://qwen.2631.eu, the plugin normalizes it to/v1automatically.OPENQWENCODE_TELEMETRY_ENDPOINT: sends a best-effort telemetryPOSTafter each final model request response.OPENQWENCODE_TELEMETRY_LINK_URL: optional override for the device-link service base URL. If unset, the plugin derives it fromOPENQWENCODE_TELEMETRY_ENDPOINT.
Example:
export OPENQWENCODE_BASE_URL="https://qwen.2631.eu"
export OPENQWENCODE_TELEMETRY_ENDPOINT="https://qwen.2631.eu/telemetry"
# optional if your link flow lives elsewhere
export OPENQWENCODE_TELEMETRY_LINK_URL="https://qwen.2631.eu"The telemetry payload is intentionally minimal:
{
"ts": "2026-04-13T12:34:56.789Z",
"deviceCode": "a1b2c3d4e5f6",
"requestCount": 1,
"attempts": 1,
"status": 200,
"durationMs": 842,
"path": "/v1/chat/completions"
}Notes:
- your telemetry server will already see the client IP at the HTTP layer, so the plugin does not send it explicitly
deviceCodeis a deterministic short hash derived from the local machine identity so you can distinguish computers without sending raw host details- the device-link flow stores its long-lived telemetry token separately in
~/.qwen/telemetry_creds.json - run
npx openqwencode linkto open the dashboard link page, enter the short code shown in the terminal, and attach this computer to one shared connection bucket - telemetry is fire-and-forget, best-effort, and disabled by default
- no official public Qwen Code reset time could be confirmed; use the UTC timestamp (
ts) to inspect your own reset pattern from collected telemetry
If you upgraded from an older published version and OpenCode still does not see the model, clear the cached package and refresh:
rm -rf ~/.cache/opencode/packages/openqwencode@latest ~/.cache/opencode/node_modules/openqwencode
opencode models --refresh- upstream
QwenLM/qwen-codeonly usescoder-modelfor the free OAuth flow qwen3-coder-plus,qwen3-vl-plus, andvision-modelare intentionally no longer exposed- the plugin injects the Qwen OAuth headers and a minimal Qwen Code system message
- the local credential file is the primary source of truth; OpenCode auth state is only used as a bootstrap/migration path
- project rules, release workflow, and backlog now live in
AGENTS.md