> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powertokens.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 万相-图生视频-基于首尾帧

> 提交一个异步的万相 2.2 图生视频任务，基于首帧（及可选尾帧）图像生成视频。

提交任务后，请通过 `GET /ali/api/v1/tasks/{task_id}` 查询任务状态。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelVideo/ali/api/legacy-i2v-first-last-frame.json POST /ali/api/v1/services/aigc/image2video/video-synthesis
openapi: 3.0.1
info:
  title: 万相-图生视频-基于首尾帧
  version: 1.0.0
  description: >-
    阿里云万相 2.2 系列基于首尾帧的图生视频能力文档。统一公开入口为
    `/ali/api/v1/services/aigc/image2video/video-synthesis`，用于创建异步视频生成任务。


    支持的模型：`wan2.2-kf2v-flash`、`wan2.1-kf2v-plus`。
  license:
    name: Project License
    url: https://github.com/QuantumNous/new-api/blob/main/LICENSE
servers:
  - url: https://api.powertokens.ai
    description: Baze API 服务地址
security: []
tags:
  - name: Wan Legacy Video
    description: Ali wan 2.2 图生视频能力
paths:
  /ali/api/v1/services/aigc/image2video/video-synthesis:
    post:
      tags:
        - Wan Legacy Video
      summary: 创建万相图生视频任务（首尾帧）
      description: |-
        提交一个异步的万相 2.2 图生视频任务，基于首帧（及可选尾帧）图像生成视频。

        提交任务后，请通过 `GET /ali/api/v1/tasks/{task_id}` 查询任务状态。
      operationId: aliLegacyI2VFirstLastFrameCreate
      parameters:
        - name: Content-Type
          in: header
          required: true
          schema:
            type: string
          description: 请求内容类型。此参数必须设置为 `application/json`。
        - name: X-DashScope-Async
          in: header
          required: true
          schema:
            type: string
          description: 异步处理配置参数。HTTP 请求只支持异步，必须设置为 `enable`。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyKf2VRequest'
            examples:
              首尾帧生视频:
                summary: 首尾帧生视频
                value:
                  model: wan2.2-kf2v-flash
                  input:
                    first_frame_url: https://wanx.alicdn.com/material/20250318/first_frame.png
                    last_frame_url: https://wanx.alicdn.com/material/20250318/last_frame.png
                    prompt: 写实风格，一只黑色小猫好奇地看向天空，镜头从平视逐渐上升，最后俯拍它的好奇的眼神。
                  parameters:
                    resolution: 480P
                    prompt_extend: true
              使用Base64:
                summary: 使用Base64
                value:
                  model: wan2.1-kf2v-plus
                  input:
                    first_frame_url: data:image/png;base64,GDU7MtCZzEbTbmRZ......
                    last_frame_url: data:image/png;base64,VBORw0KGgoAAAANSUh......
                    prompt: 写实风格，一只黑色小猫好奇地看向天空，镜头从平视逐渐上升，最后俯拍它的好奇的眼神。
                  parameters:
                    resolution: 720P
                    prompt_extend: true
              使用视频特效:
                summary: 使用视频特效
                value:
                  model: wan2.1-kf2v-plus
                  input:
                    first_frame_url: >-
                      https://ty-yuanfang.oss-cn-hangzhou.aliyuncs.com/lizhengjia.lzj/tmp/11.png
                    template: hanfu-1
                  parameters:
                    resolution: 720P
                    prompt_extend: true
              使用反向提示词:
                summary: 使用反向提示词
                value:
                  model: wan2.1-kf2v-plus
                  input:
                    first_frame_url: https://wanx.alicdn.com/material/20250318/first_frame.png
                    last_frame_url: https://wanx.alicdn.com/material/20250318/last_frame.png
                    prompt: 写实风格，一只黑色小猫好奇地看向天空，镜头从平视逐渐上升，最后俯拍它的好奇的眼神。
                    negative_prompt: 人物
                  parameters:
                    resolution: 720P
                    prompt_extend: true
      responses:
        '200':
          description: 提交成功，返回视频任务对象。请保存 task_id，用于查询任务状态与结果。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTaskResponse'
              example:
                output:
                  task_status: PENDING
                  task_id: 0385dc79-5ff8-4d82-bcb6-xxxxxx
                request_id: 4909100c-7b5a-9f92-bfe5-xxxxxx
        '400':
          description: 请求参数不合法。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 鉴权失败，例如未提供令牌或令牌无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: 触发速率限制或账户额度不足。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 服务端处理请求时发生内部错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    LegacyKf2VRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - wan2.2-kf2v-flash
            - wan2.1-kf2v-plus
          description: 模型名称。示例值：`wan2.2-kf2v-flash`。详情参见百炼控制台。
        input:
          $ref: '#/components/schemas/LegacyKf2VInput'
        parameters:
          $ref: '#/components/schemas/LegacyKf2VParameters'
    VideoTaskResponse:
      type: object
      properties:
        output:
          type: object
          properties:
            task_id:
              type: string
              description: 任务ID。查询有效期24小时。
            task_status:
              type: string
              description: |-
                任务状态。

                枚举值：
                - `PENDING`：任务排队中
                - `RUNNING`：任务处理中
                - `SUCCEEDED`：任务执行成功
                - `FAILED`：任务执行失败
                - `CANCELED`：任务已取消
                - `UNKNOWN`：任务不存在或状态未知
            code:
              type: string
              description: 请求失败的错误码。请求成功时不会返回此参数。
            message:
              type: string
              description: 请求失败的详细信息。请求成功时不会返回此参数。
        request_id:
          type: string
          description: 请求唯一标识。可用于请求明细溯源和问题排查。
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: 错误码。
        message:
          type: string
          description: 错误信息。
        request_id:
          type: string
          description: 请求 ID。
    LegacyKf2VInput:
      type: object
      required:
        - first_frame_url
      properties:
        prompt:
          type: string
          description: |-
            文本提示词。支持中英文，长度不超过800个字符，每个汉字/字母占一个字符，超过部分会自动截断。

            如果首尾帧的主体和场景变化较大，建议描写变化过程，例如运镜过程（镜头向左移动）或者主体运动过程（人向前奔跑）。

            示例值：一只黑色小猫好奇地看向天空，镜头从平视逐渐上升，最后俯拍它的好奇的眼神。
          maxLength: 800
        negative_prompt:
          type: string
          description: |-
            反向提示词，用来描述不希望在视频画面中看到的内容，可以对视频画面进行限制。

            支持中英文，长度不超过500个字符，超过部分会自动截断。

            示例值：低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。
          maxLength: 500
        first_frame_url:
          type: string
          description: >-
            首帧图像的URL或 Base64 编码数据。输出视频的宽高比将以此图像为基准。


            图像限制：

            - 图像格式：JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP。

            - 图像分辨率：图像的宽度和高度范围为[240,8000]，单位为像素。

            - 文件大小：不超过10MB。


            支持输入的格式：

            - **公网URL**：支持 HTTP 或 HTTPS
            协议。示例值：`https://wanx.alicdn.com/xxx/first_frame.png`。

            - **临时URL**：支持OSS协议，必须通过上传文件获取临时
            URL。示例值：`oss://dashscope-instant/xxx/xxx.png`。

            - **Base64
            编码图像后的字符串**：数据格式：`data:{MIME_type};base64,{base64_data}`。示例值：`data:image/png;base64,GDU7MtCZzEbTbmRZ......`（编码字符串过长，仅展示片段）。
        last_frame_url:
          type: string
          description: >-
            尾帧图像的URL或 Base64 编码数据。


            图像限制：

            - 图像格式：JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP。

            - 图像分辨率：图像的宽度和高度范围为[240,8000]，单位为像素。尾帧图像分辨率可与首帧不同，无需强制对齐。

            - 文件大小：不超过10MB。


            支持输入的格式：

            - **公网URL**：支持 HTTP 或 HTTPS
            协议。示例值：`https://wanx.alicdn.com/xxxx/last_frame.png`。

            - **临时URL**：支持OSS协议，必须通过上传文件获取临时
            URL。示例值：`oss://dashscope-instant/xxx/xxx.png`。

            - **Base64
            编码图像后的字符串**：数据格式：`data:{MIME_type};base64,{base64_data}`。示例值：`data:image/png;base64,GDU7MtCZ......`（编码字符串过长，仅展示片段）。
        template:
          type: string
          description: |-
            视频特效模板的名称。使用此参数时，仅需传入 first_frame_url。

            不同模型支持不同的特效模板。调用前请查阅万相-图生视频-视频特效，以免调用失败。

            示例值：`hufu-1`，表示使用「唐韵翩然」特效。
    LegacyKf2VParameters:
      type: object
      properties:
        resolution:
          type: string
          enum:
            - 480P
            - 720P
            - 1080P
          description: >-
            **重要**：resolution直接影响费用，同一模型：1080P > 720P > 480P。


            生成的视频分辨率档位。仅用于调整视频的清晰度（总像素），不改变视频的宽高比，视频宽高比将与首帧图像 first_frame_url
            的宽高比保持一致。


            此参数的默认值和可用枚举值依赖于 model 参数，规则如下：

            - `wan2.2-kf2v-flash`：可选值：480P、720P、1080P。默认值为720P。

            - `wan2.1-kf2v-plus`：可选值：720P。默认值为720P。


            示例值：720P。
        duration:
          type: integer
          description: |-
            **重要**：duration直接影响费用，按秒计费。

            视频生成时长，单位为秒。当前参数值固定为5，且不支持修改。模型将始终生成5秒时长的视频。
          default: 5
        prompt_extend:
          type: boolean
          description: |-
            是否开启prompt智能改写。开启后使用大模型对输入prompt进行智能改写。对于较短的prompt生成效果提升明显，但会增加耗时。

            - `true`：默认值，开启智能改写。
            - `false`：不开启智能改写。

            示例值：true。
          default: true
        watermark:
          type: boolean
          description: |-
            是否添加水印标识，水印位于图片右下角，文案为「AI生成」。

            - `false`：默认值，不添加水印。
            - `true`：添加水印。

            示例值：false。
          default: false
        seed:
          type: integer
          description: |-
            随机数种子，取值范围为[0, 2147483647]。

            未指定时，系统自动生成随机种子。若需提升生成结果的可复现性，建议固定seed值。

            请注意，由于模型生成具有概率性，即使使用相同 seed，也不能保证每次生成结果完全一致。
          minimum: 0
          maximum: 2147483647
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````