跳转到主要内容
万相2.6

Wan 2.6 — 创建任务

Wan 2.6 异步图像生成与编辑

POST
/services/aigc/image-generation/generation
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'X-DashScope-Async: enable' \
--data '{
  "model": "wan2.6-image",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "text": "Generate a tomato and egg stir-fry based on the style of image 1 and the background of image 2"
          },
          {
            "image": "https://cdn.wanx.aliyuncs.com/tmp/pressure/umbrella1.png"
          },
          {
            "image": "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"
          }
        ]
      }
    ]
  },
  "parameters": {
    "prompt_extend": true,
    "watermark": false,
    "n": 1,
    "enable_interleave": false,
    "size": "1K"
  }
}'
{
  "output": {
    "task_status": "PENDING",
    "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
  },
  "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}
获取 API Key设置为环境变量。如需使用 SDK,请先安装 SDK
图像生成任务通常需要 1 到 2 分钟。为避免请求超时,可使用异步 API 将流程拆分为两步:
  1. 创建任务(本接口),获取 task_id
  2. 查询结果,使用 task_id 轮询任务状态。
请求体与同步接口使用相同的 messages 格式和参数,但需要添加 X-DashScope-Async: enable 请求头。

鉴权

string
header
必填

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

Header 参数

enum<string>
必填

异步处理配置。必须设置为 enable

enable

请求体

application/json
enum<string>
必填

模型名称。设置为 wan2.6-image

wan2.6-image
wan2.6-image
object
必填

包含消息数组的输入数据。

object

图像处理参数。

响应

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

用于排查问题的唯一请求标识符。

object