跳转到主要内容
千问

Qwen — 异步图像生成

异步图像生成

POST
/services/aigc/text2image/image-synthesis
curl -X POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis \
  -H 'X-DashScope-Async: enable' \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "qwen-image-plus",
  "input": {
    "prompt": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass."
  },
  "parameters": {
    "negative_prompt": "",
    "size": "1664*928",
    "n": 1,
    "prompt_extend": true,
    "watermark": false
  }
}'
{
  "output": {
    "task_status": "PENDING",
    "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
  },
  "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}
获取 API Key配置环境变量。如果使用 SDK,还需安装 SDK。此异步接口仅支持 qwen-image-plusqwen-image 模型,其他模型请使用同步接口

调用流程

  1. 提交任务:通过 POST /services/aigc/text2image/image-synthesis 提交任务,请求头中需包含 X-DashScope-Async: enable
  2. 轮询结果:通过 GET /tasks/{task_id} 查询任务状态,直到 task_status 变为 SUCCEEDEDFAILED。建议每 10 秒轮询一次。

鉴权

string
header
必填

千问云 API Key。详见获取 API Key

Header 参数

enum<string>
必填

异步任务提交时必须设置为 enable

enable

请求体

application/json
enum<string>
必填

模型名称。异步调用仅支持 qwen-image-plusqwen-image

qwen-image-plus,qwen-image
qwen-image-plus
object
必填

输入数据。

object

Qwen-Image 异步调用的生成参数。

响应

200-application/json
string
默认值"4909100c-7b5a-9f92-bfe5-xxxxxx"

唯一请求标识符。

object