POST /v1/images/generations
## Aliyun Qwen-Image Multimodal (multimodal image generation/editing) Qwen image generation multimodal API. Supported models: | Model | Type | Description | |---|---|---| | `qwen-image-2.0` | Text-to-Image | 2.0 Basic version | | `qwen-image-2.0-pro` | Text-to-Image | 2.0 High-quality enhanced version | | `qwen-image-max` | Text-to-Image | Flagship high quality | | `qwen-image-edit` | Image editing | Must provide 1-3 reference images | | `qwen-image-edit-plus` | Image editing | Editing enhanced version | | `qwen-image-edit-max` | Image editing | Editing flagship version | ### Body structure - `input.messages[]` array — a user message contains multiple content blocks - Each `content[]` block: - `{"text": "提示词"}` — text prompt - `{"image": "https://..."}` — reference image URL, must be publicly accessible (https) ### Model protocol requirements | Model | content must include | Notes | |---|---|---| | qwen-image-2.0 / -2.0-pro / -max | 1 `{text}` | Pure text-to-image, optionally 0 `{image}` | | qwen-image-edit / -edit-plus / -edit-max | 1 `{text}` + **1-3 `{image}`** | Reference image required | ### Response parsing - `output.choices[0].message.content[]` — array, containing 1 `{"image": "https://..."}` blocks - `usage.image_count` / `usage.height` / `usage.width` — generated image information ### Basic text-to-image (no reference image) If only simple text-to-image (no multimodal) is needed, you can also use the lighter [Aliyun Qwen-Image text-to-image](/docs/api/aliyun-qwen-image) API (qwen-image / qwen-image-plus).
model | string | required | Qwen-Image multimodal model. `-2.0` / `-2.0-pro` / `-max` text-to-image; `-edit*` series requires 1-3 reference images for editing |
input | object | required | Input object, containing a messages array |
messages | array | required | Conversation message array. The current image scenario only supports a single user message |
role | string | required | Message role. Currently only supports 'user' |
content | array | required | Content block array. Must contain at least 1 `{text}`. Editing models must also include 1-3 `{image}` reference images |
text | string | Text prompt (only one of `text` or `image` per content block) | |
image | string | Reference image URL (https), internal download via Aliyun. URL must be publicly accessible | |
parameters | object | Generation parameters | |
size | string | Image dimensions, DashScope style (`*` separated) | |
n | integer | Number of generated images. Current upstream limits to 1 images per request | |
seed | integer | Random seed. Identical prompt and seed yield similar results, useful for style tuning | |
watermark | boolean | Whether to add watermark | |
negative_prompt | string | Negative prompt — elements the model should avoid | |
prompt_extend | boolean | Whether to enable prompt intelligent expansion (upstream automatically supplements details) |
200 — Generation successful, returns image URL400 — Parameter error, e.g., missing reference image for editing models / unrecognized model name / unsupported size429 — Request frequency or concurrency exceededcurl -X POST "https://api.router.ai/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-edit",
"input": {
"messages": [
{
"role": "user",
"content": [
{"text": "把这张图改成赛博朋克风格, 加上霓虹灯"},
{"image": "https://example.com/reference.png"}
]
}
]
},
"parameters": {
"size": "1024*1024",
"n": 1,
"seed": 42
}
}'