Skip to content

About

OpenCode plugin that adds an image_generate tool for text-to-image generation with Alibaba DashScope models (qwen-image, wan)

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

Repository files navigation

opencode-dashscope-imagegen

English | Русский

Text-to-image generation for OpenCode via Alibaba DashScope — qwen-image-2.0, qwen-image-3.0 and wan2.7-image exposed as an image_generate tool your coding agent can call.

npm version npm downloads license OpenCode plugin

Example output: generated with qwen-image-2.0

Highlights

  • Adds a single image_generate tool to any OpenCode agent — no extra server, no MCP setup.
  • Uses the native DashScope multimodal-generation endpoint (the OpenAI-compatible /v1/images/generations route 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:
    1. DASHSCOPE_IMAGEGEN_API_KEY env
    2. DASHSCOPE_API_KEY env
    3. apiKey of any dashscope* provider in your opencode.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

Example (replace with a real one)

npm start

Example (replace with a real one)

npm start

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.
  • size rejected — use W*H with * (star), not x: 1024*1024.
  • Model not supported — the key's account must have the model enabled in Model Studio.

Related

License

MIT

Who is it for

Use cases

Why choose this

About

OpenCode plugin that adds an image_generate tool for text-to-image generation with Alibaba DashScope models (qwen-image, wan)

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages