模型概览
- 端点
- /api/v1/images/generations
- 积分成本
- 4 credits at 1K, 8 at 2K
- 典型耗时
- Async
- 输入与输出
- Text, up to 10 images → PNG, WebP, or JPEG
能力
- 1K and 2K output
- Up to 10 reference images
- Local mask edits
- Transparent PNG or WebP
请求参数
| 参数 | 类型 | 要求 | 说明 |
|---|---|---|---|
| model | string | 必填 | Model identifier. 默认值: qwen-image-2.1 |
| prompt | string | 必填 | Generation or edit prompt, up to 5000 characters. |
| image_urls | string[] | 可选 | One to ten public image URLs. Supplying images switches the request to image editing. |
| aspect_ratio | string | 可选 | Text-to-image ratios are 1:1, 4:3, 3:4, 3:2, 2:3, 16:9, and 9:16. Image editing also accepts auto. 默认值: 3:2 for text-to-image, auto for edits |
| resolution | 1K | 2K | 可选 | Output resolution tier. 2K costs more credits than 1K. 默认值: 1K |
| background | opaque | transparent | 可选 | Transparent output cannot be JPEG, and cannot be combined with a mask. 默认值: opaque |
| output_format | png | webp | jpeg | 可选 | Generated file format. 默认值: png |
| enhance_prompt | boolean | 可选 | Expand the prompt before generation. prompt_extend is accepted as an alias. 默认值: true |
| seed | integer | 可选 | Integer from 0 to 2147483647. 默认值: 0 |
| mask_url | string | 可选 | Public mask URL for a local edit. Requires exactly one reference image and an opaque background. |
请求示例
curl https://qwenapi.org/api/v1/images/generations \
-H "Authorization: Bearer $QWEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.1",
"prompt": "Editorial poster for a night market, bold headline NIGHT MARKET, gold ink on charcoal paper, wide margins",
"aspect_ratio": "3:2",
"resolution": "1K",
"output_format": "png"
}'生成端点为异步任务。请使用同一个 Bearer 密钥轮询 GET /api/v1/tasks/。
