跳转到主要内容
首尾帧

PixVerse — 创建任务

提交 PixVerse 首尾帧图生视频任务

POST
/services/aigc/video-generation/video-synthesis
cURL
curl --location 'https://maas.qianwenaiapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
  -H 'X-DashScope-Async: enable' \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "pixverse/pixverse-c1-kf2v",
  "input": {
    "media": [
      {"type": "first_frame", "url": "https://wanx.alicdn.com/material/20250318/first_frame.png"},
      {"type": "last_frame", "url": "https://wanx.alicdn.com/material/20250318/last_frame.png"}
    ],
    "prompt": "一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。"
  },
  "parameters": {
    "resolution": "720P",
    "duration": 5,
    "watermark": true
  }
}'
{
  "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx",
  "output": {
    "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx",
    "task_status": "PENDING"
  }
}
根据首帧图像、尾帧图像和文本提示词,生成平滑过渡的视频。

模型选择

  • pixverse/pixverse-c1-kf2v:擅长打斗、法术特效和高速运动场景。
  • pixverse/pixverse-v6-kf2v:通用模型。
  • pixverse/pixverse-v5.6-kf2v:旧版模型,建议升级至 v6。
  • Python SDK
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os

# 若没有配置环境变量,请用千问AI平台API Key将下行替换为:api_key="sk-xxx"
# 获取API Key:https://platform.qianwenai.com/home/api-keys
api_key = os.getenv("DASHSCOPE_API_KEY")

media = [{'type': 'first_frame', 'url': 'https://wanx.alicdn.com/material/20250318/first_frame.png'}, {'type': 'last_frame', 'url': 'https://wanx.alicdn.com/material/20250318/last_frame.png'}]

def sample_async_call():
    # 异步提交视频生成任务
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                model='pixverse/pixverse-c1-kf2v',
                                media=media,
                                prompt='一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。',
                                resolution='720P',
                                duration=5,
                                watermark=True)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print("task_id: %s" % rsp.output.task_id)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

    # 查询任务状态
    status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
    if status.status_code == HTTPStatus.OK:
        print(status.output.task_status)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (status.status_code, status.code, status.message))

    # 等待任务完成
    rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output.video_url)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

if __name__ == '__main__':
    sample_async_call()

鉴权

string
header
必填

千问AI平台 API Key。详见获取 API Key。

Header 参数

enum<string>
必填

异步处理配置参数。HTTP请求只支持异步,必须设置为 enable。缺少此请求头将报错:"current user api does not support synchronous calls"。

enable

请求体

application/json
enum<string>
必填

模型名称。可选值:pixverse/pixverse-c1-kf2v(针对打斗、法术特效及高速运动等动态场景)、pixverse/pixverse-v6-kf2v(通用场景)、pixverse/pixverse-v5.6-kf2v(建议升级至v6)。

pixverse/pixverse-c1-kf2v,pixverse/pixverse-v6-kf2v,pixverse/pixverse-v5.6-kf2v
pixverse/pixverse-c1-kf2v
object
必填

输入的基本信息,包含首帧、尾帧图像和提示词。

object

视频生成参数。如设置视频分辨率、时长、是否生成音频等。

响应

200-application/json
string

请求唯一标识。可用于请求明细溯源和问题排查。

4909100c-7b5a-9f92-bfe5-xxxxxx
object