opencode-dashscope-imagegen
v0.1.3
Published
OpenCode plugin that adds an image_generate tool for text-to-image generation with Alibaba DashScope models (qwen-image-2.0, qwen-image-3.0, wan2.7-image)
Maintainers
Readme
opencode-dashscope-imagegen
Text-to-image generation for OpenCode via Alibaba DashScope —
qwen-image-2.0,qwen-image-3.0andwan2.7-imageexposed as animage_generatetool your coding agent can call.

Highlights
- Adds a single
image_generatetool to any OpenCode agent — no extra server, no MCP setup. - Uses the native DashScope multimodal-generation endpoint (the OpenAI-compatible
/v1/images/generationsroute is not served by DashScope). - Saves the PNG to disk and returns the absolute path, so vision models
(
qwen3-vl-plus,kimi-k3, …) can inspect the result via normal image attachments. - Works with any DashScope text-to-image model, including the Wan series (
wan2.7-image).
Supported models
| Model | Notes |
| -------------------------- | ---------------------------------- |
| qwen-image-2.0 (default) | fast general-purpose text-to-image |
| qwen-image-3.0 | newer Qwen-Image generation |
| wan2.7-image | Wan (Tongyi Wanxiang) image models |
Prerequisites
- OpenCode installed.
- A DashScope API key from Alibaba Cloud Model Studio
(Bailian console). Key resolution order:
DASHSCOPE_IMAGEGEN_API_KEYenvDASHSCOPE_API_KEYenvapiKeyof anydashscope*provider in youropencode.json
Installation
Add the npm package name to your opencode.json — OpenCode installs it on next launch:
{
"plugin": ["opencode-dashscope-imagegen"]
}Developing locally
To run from a checkout instead of npm, reference the plugin directory and install its
dependencies once (@opencode-ai/plugin must resolve from the plugin's own directory):
{
"plugin": ["file:///path/to/opencode-dashscope-imagegen"]
}npm install
npm run build # tsc → dist/ (js + d.ts)Usage
Just ask your agent: "generate an image of a lighthouse at dusk" — it will call the tool:
| Arg | Default | Description |
| ------------- | ---------------- | --------------------------------------------------------- |
| prompt | required | image description |
| model | qwen-image-2.0 | any DashScope text-to-image model |
| size | 1024*1024 | W*H with a star, e.g. 1280*720 |
| output_path | auto | absolute path; default <config>/gen-images/gen-<ts>.png |
Output directory override: DASHSCOPE_IMAGEGEN_DIR env.
Troubleshooting
InvalidApiKey/ 401 — no key found; check the resolution order above.- Tool not appearing — restart OpenCode after editing
opencode.json; plugins load at startup. sizerejected — useW*Hwith*(star), notx:1024*1024.- Model not supported — the key's account must have the model enabled in Model Studio.
