QwenCloud Token Plan

Chat models for opencode with a config-only provider

A single JSON file exposes six chat models through QwenCloud's OpenAI-compatible API — no build needed for chat. Streaming, tool calls, and usage tracking work out of the box. Wan image generation and HappyHorse video come as a plugin you can install via npm or drop a single bundled file into your opencode config.

// opencode.json — the whole chat provider
"provider": {
  "qwencloud": {
    "npm":     "@ai-sdk/openai-compatible",
    "name":    "QwenCloud",
    "options": {
      "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
      "apiKey":  "{env:QWENCLOUD_API_KEY}"
    },
    "models":  { … }
  }
}

Chat provider requires no build. The plugin compiles separately with tsup.

Models

Model Reasoning
Qwen3.8 Max Preview yes
Qwen3.7 Max yes
Qwen3.7 Plus yes
Qwen3.6 Flash yes
DeepSeek V4 Pro yes
GLM-5.2 yes

Install

Copy the config file

Drop opencode.json into your global or project-level opencode config. Project-level takes precedence over global.

# Global config (all projects)
cp opencode.json ~/.config/opencode/

# Per-project (merges with your existing opencode.jsonc)
cp opencode.json ./path/to/project/

Set your API key

The chat config uses {env:QWENCLOUD_API_KEY} so your key never lands in a committed file. The plugin also reads from /connect inline config — set the key once and both tiers pick it up.

# Persistent
echo 'export QWENCLOUD_API_KEY="your_key_here"' >> ~/.zshrc
source ~/.zshrc

# Single session (or use /connect in opencode for plugin-only)
QWENCLOUD_API_KEY=sk-... opencode

Media generation

Wan images and HappyHorse video as native opencode tools

The AI calls them autonomously when you ask for image or video generation. Or use /wan and /happyhorse slash commands.

Wan image generation

Text-to-image with wan2.7-image and wan2.7-image-pro. Synchronous API — output at 1K, 2K, 4K, saved to your working directory immediately.

/wan a cyberpunk cat in neon rain

HappyHorse video generation

Text-to-video, image-to-video, reference-to-video. Async with progress polling. 3 to 15 second output.

/happyhorse a drone shot over the ocean

Plugin setup

Local install

# Build the single-file bundle, then copy into opencode
npm install && npm run build
cp dist/opencode-qwencloud-provider.js ~/.config/opencode/plugins/
# Plus slash-command files
cp command/wan.md command/happyhorse.md ~/.config/opencode/command/

npm install

"plugin": ["opencode-qwencloud-provider"]

Features

Config-only chat provider
The chat provider requires zero build — opencode reads the JSON directly. Streaming, tool calls, and usage tracking work through the OpenAI-compatible transport. The plugin compiles separately with tsup (or install from npm with no build).
Env-var auth
Key interpolated from QWENCLOUD_API_KEY via opencode's {env:VAR} syntax. Safe to commit, safe to share. Inline-key fallback available for environments that cannot set env vars.
Custom tools for media
Wan and HappyHorse registered as native opencode tools via @opencode-ai/plugin. The AI decides when to call them — no special syntax or manual workflow.
Refreshable model list
Run fetch-models.mjs to pull the live QwenCloud catalog. Auto-filters non-chat families (Wan, HappyHorse, qwen-image) so the models map stays clean.
Smoke tested
Four live API checks run against the real endpoint: basic completion, SSE streaming, tool calls, and a second model verification. smoke-test.mjs mirrors the exact request shape opencode sends.
Validated config
validate.mjs checks JSON syntax and required provider fields. CI runs it on every push. Zero dependencies, Node 20 and above.

Compare

opencode pi
Form factor JSON config + TS plugin TypeScript package
Chat provider build None tsup
Auth {env:VAR}, inline key, or /connect env, /login, auth.json
Model discovery Static, refreshable script Dynamic at startup
Wan / HappyHorse custom tools slash commands

Developer tooling

Command Description
npm run lint oxlint with TypeScript, unicorn, oxc, import plugins
npm run format Auto-format with oxfmt
npm test Unit tests via vitest with mocked fetch
npm run smoke-test Four live API checks against QwenCloud endpoint
npm run fetch-models Pull live model catalog from /models endpoint
npm run validate Check JSON syntax and required provider fields
npm run build Compile plugin TypeScript with tsup

One JSON file, one env var (or /connect)

Plus Wan and HappyHorse as native opencode tools. Drop the config, set your key, build the plugin, start using QwenCloud models.

View on GitHub