跳转到主要内容
万相2.7

Wan 2.7 — 创建任务

Wan 2.7 异步图像生成与编辑

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.7-image-pro",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "text": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
          }
        ]
      }
    ]
  },
  "parameters": {
    "n": 1,
    "size": "2K",
    "watermark": false,
    "thinking_mode": true
  }
}'
{
  "request_id": "ccf4b2f4-bf30-9e13-9461-3a28c6a7bxxx",
  "output": {
    "task_id": "8811b4a4-00ac-4aa2-a2fd-017d3b90cxxx",
    "task_status": "PENDING"
  }
}
获取 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.7-image-pro、wan2.7-image。

wan2.7-image-pro,wan2.7-image
wan2.7-image-pro
object
必填

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

object

图像处理参数。

响应

200-application/json
string
默认值"ccf4b2f4-bf30-9e13-9461-3a28c6a7bxxx"

唯一请求标识符。

ccf4b2f4-bf30-9e13-9461-3a28c6a7bxxx
object