Wan 2.7 — 同步调用 - 千问云
跳转到主要内容
万相 2.6

Wan 2.6 — 查询结果

查询视频生成任务状态

GET
/tasks/{task_id}
cURL - 查询任务结果
# 将 {task_id} 替换为提交任务时返回的实际任务 ID
curl -X GET 'https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}' \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
{
  "request_id": "c1209113-8437-424f-a386-xxxxxx",
  "output": {
    "task_id": "966cebcd-dedc-4962-af88-xxxxxx",
    "task_status": "SUCCEEDED",
    "video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
    "task_metrics": {
      "TOTAL": 1,
      "SUCCEEDED": 1,
      "FAILED": 0
    }
  },
  "usage": {
    "video_count": 1,
    "video_duration": 5
  }
}
查询任务状态并获取生成的视频。

轮询策略

  1. 创建任务,获取 task_id
  2. 15 秒轮询一次,直到 task_statusSUCCEEDEDFAILED
  3. 任务成功后,从 video_url 获取视频。

注意事项

  • URL 有效期:视频 URL 在 24 小时后过期,请及时下载。
  • 状态流转PENDINGRUNNINGSUCCEEDEDFAILED

鉴权

string
header
必填

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

路径参数

string
必填

视频创建接口返回的任务标识符。

响应

200-application/json
string

请求唯一标识符。

object
object

用量统计(仅在任务成功时出现)。

万相2.7

Wan 2.7 — 同步调用

Wan 2.7 同步图像生成与编辑

POST
/services/aigc/multimodal-generation/generation
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
  "model": "wan2.7-image-pro",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "text": "A serene mountain lake at sunrise, with mist rising from the water, surrounded by pine trees, photorealistic"
          }
        ]
      }
    ]
  },
  "parameters": {
    "n": 1,
    "size": "2K",
    "watermark": false,
    "thinking_mode": true
  }
}'
{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "content": [
            {
              "image": "https://dashscope-result.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx",
              "type": "image"
            }
          ],
          "role": "assistant"
        }
      }
    ],
    "finished": true
  },
  "usage": {
    "image_count": 1,
    "input_tokens": 18790,
    "output_tokens": 2,
    "size": "2985*1405",
    "total_tokens": 18792
  },
  "request_id": "a3f4befe-cacd-49c9-8298-xxxxxx"
}
获取 API Key设置为环境变量。如需使用 SDK,请先安装 SDK
该同步接口支持 wan2.7-image-prowan2.7-image 模型。通过单次请求即可直接获取生成的图像,无需轮询。 如需异步处理,请使用异步提交接口。

鉴权

string
header
必填

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

请求体

application/json
enum<string>
必填

模型名称。可选值:wan2.7-image-pro、wan2.7-image。

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

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