> ## 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.

# wan2.7-i2v 首尾帧图生视频

> 提交一个异步的 Ali `wan2.7-i2v` 首尾帧生视频任务。

使用 `first_frame` 指定首帧图像，`last_frame` 指定尾帧图像，可选搭配 `driving_audio` 驱动音频。

支持的 `media` 组合为：
- `first_frame + last_frame`
- `first_frame + last_frame + driving_audio`

本能力下 `prompt` 为可选字段。`size` 仅支持 `720P` 与 `1080P`。`seconds` 仅支持 `2` 到 `15` 的整数字符串。还支持官方字段 `negative_prompt`、`prompt_extend`、`watermark` 与 `seed`。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelVideo/ali/wan2.7-i2v-first-last-frame.json POST /v1/videos
openapi: 3.0.1
info:
  title: wan2.7-i2v 首尾帧生视频
  version: 1.0.0
  description: >-
    面向客户的 Ali `wan2.7-i2v` 首尾帧生视频渠道文档，统一公开入口为 `/v1/videos`。


    本文档描述首尾帧生视频场景，并使用顶层 `media` 数组表达上游新版 `input.media` 协议。


    本场景支持的 `media.type` 为 `first_frame`、`last_frame`、`driving_audio`。


    支持的 `media` 组合为：

    - `first_frame + last_frame`

    - `first_frame + last_frame + driving_audio`


    本能力下 `prompt` 为可选字段。`size` 仅支持 `720P` 与 `1080P`。`seconds` 仅支持 `2` 到 `15`
    的整数字符串。还支持官方字段 `negative_prompt`、`prompt_extend`、`watermark` 与 `seed`。
  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 2.7 Video
    description: Ali wan2.7-i2v 首尾帧生视频能力
paths:
  /v1/videos:
    post:
      tags:
        - Wan 2.7 Video
      summary: 创建 wan2.7-i2v 首尾帧生视频任务
      description: >-
        提交一个异步的 Ali `wan2.7-i2v` 首尾帧生视频任务。


        使用 `first_frame` 指定首帧图像，`last_frame` 指定尾帧图像，可选搭配 `driving_audio` 驱动音频。


        支持的 `media` 组合为：

        - `first_frame + last_frame`

        - `first_frame + last_frame + driving_audio`


        本能力下 `prompt` 为可选字段。`size` 仅支持 `720P` 与 `1080P`。`seconds` 仅支持 `2` 到 `15`
        的整数字符串。还支持官方字段 `negative_prompt`、`prompt_extend`、`watermark` 与 `seed`。
      operationId: aliWan27I2VFirstLastFrame
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Wan27FirstLastFrameRequest'
            examples:
              first_last_frame:
                summary: 首帧 + 尾帧
                value:
                  model: wan2.7-i2v
                  prompt: 一只猫从走廊这端走到另一端。
                  media:
                    - type: first_frame
                      url: https://example.com/assets/start.png
                    - type: last_frame
                      url: https://example.com/assets/end.png
                  seconds: '5'
                  size: 1080P
              first_last_frame_with_audio:
                summary: 首帧 + 尾帧 + 驱动音频
                value:
                  model: wan2.7-i2v
                  prompt: 人物逐渐抬头微笑，伴随旁白。
                  negative_prompt: 模糊，低质量
                  prompt_extend: true
                  watermark: false
                  seed: 42
                  media:
                    - type: first_frame
                      url: https://example.com/assets/portrait-start.png
                    - type: last_frame
                      url: https://example.com/assets/portrait-end.png
                    - type: driving_audio
                      url: https://example.com/assets/narration.mp3
                  seconds: '8'
                  size: 720P
      responses:
        '200':
          description: 提交成功，返回统一的 OpenAI 风格视频任务对象。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTaskResponse'
        '400':
          description: 请求参数非法，例如 `media` 组合不受支持，或 `size` / `seconds` 超出项目当前支持范围。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request:
                  summary: 非法请求
                  value:
                    error:
                      message: unsupported wan2.7-i2v media combination
                      type: invalid_request_error
                      code: invalid_request
        '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:
    Wan27FirstLastFrameRequest:
      type: object
      required:
        - model
        - media
      properties:
        model:
          type: string
          enum:
            - wan2.7-i2v
          description: 模型名称。可选值：`wan2.7-i2v`。
        prompt:
          type: string
          description: >-
            文本提示词。用来描述生成视频中期望包含的元素和视觉特点。支持中英文，长度不超过5000个字符。每个汉字/字母占一个字符，超过部分会自动截断。
        size:
          type: string
          enum:
            - 720P
            - 1080P
          description: |-
            指定生成的视频分辨率档位，用于控制视频的清晰度（总像素）。

            模型根据选择的分辨率档位，自动缩放至相近总像素。视频宽高比尽量与输入素材（首帧或首段视频）保持一致。
          default: 1080P
        seconds:
          type: string
          description: 视频时长的字符串形式。当前支持 `2` 到 `15` 的整数字符串。
          default: '5'
          enum:
            - '2'
            - '3'
            - '4'
            - '5'
            - '6'
            - '7'
            - '8'
            - '9'
            - '10'
            - '11'
            - '12'
            - '13'
            - '14'
            - '15'
        negative_prompt:
          type: string
          description: >-
            反向提示词，用来描述不希望在视频画面中看到的内容，可以对视频画面进行限制。支持中英文，长度不超过500个字符，超过部分会自动截断。示例值：低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。
        prompt_extend:
          type: boolean
          description: >-
            是否开启 prompt 智能改写。开启后使用大模型对输入 prompt 进行智能改写。对于较短的 prompt
            生成效果提升明显，但会增加耗时。`true`（默认值）：开启智能改写。`false`：不开启智能改写。
        watermark:
          type: boolean
          description: 是否添加水印标识，水印位于视频右下角，文案固定为 "AI生成"。`false`（默认值）：不添加水印。`true`：添加水印。
          default: false
        seed:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: >-
            随机数种子，取值范围为 [0, 2147483647]。未指定时，系统自动生成随机种子。若需提升生成结果的可复现性，建议固定 seed
            值。请注意，由于模型生成具有概率性，即使使用相同 seed，也不能保证每次生成结果完全一致。
        media:
          type: array
          description: |-
            媒体素材列表，用于指定视频生成所需的参考素材（图像、音频和视频）。数组的每个元素为一个媒体对象，包含 type 与 url 字段。

            素材组合（仅支持以下特定的组合，非法组合将报错）：
            - **首尾帧生视频**：`first_frame` + `last_frame`
            - **首尾帧+音频**：`first_frame` + `last_frame` + `driving_audio`

            每种 type 在 media 数组中最多出现一次（例如：不可同时传入两个 first_frame）。
          items:
            $ref: '#/components/schemas/Wan27MediaInput'
    VideoTaskResponse:
      type: object
      properties:
        id:
          type: string
          description: 公开任务 ID。
        task_id:
          type: string
          description: 公开任务 ID 的兼容别名。
        object:
          type: string
          example: video
        model:
          type: string
          description: 模型名称。
        status:
          type: string
          enum:
            - queued
            - in_progress
            - completed
            - failed
            - unknown
          description: 统一的视频任务状态。
        progress:
          type: integer
          description: 任务进度百分比。
        created_at:
          type: integer
          format: int64
          description: Unix 秒级时间戳。
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
    Wan27MediaInput:
      type: object
      required:
        - type
        - url
      properties:
        type:
          type: string
          enum:
            - first_frame
            - last_frame
            - driving_audio
          description: |-
            媒体素材类型。可选值为：
            - `first_frame`：首帧。
            - `last_frame`：尾帧。
            - `driving_audio`：驱动音频。

            使用限制：每种 type 在 media 数组中最多出现一次（例如：不可同时传入两个 first_frame）。
        url:
          type: string
          description: >-
            媒体素材URL。素材包括图像、音频和视频。


            **音频**（type=`driving_audio`）


            音频文件的 URL。


            - **传入音频**：模型将以该音频为驱动源生成视频（如口型同步、动作卡点等）。

            - **未传入音频**：模型将根据视频画面内容，自动生成匹配的背景音乐或音效。


            音频限制：


            - 格式：wav、mp3。

            - 时长：2～30s。

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

            - 截断处理：若音频长度超过 duration
            值（如5秒），自动截取前5秒，其余部分丢弃。若音频长度不足视频时长，超出音频长度部分为无声视频。例如，音频为3秒，视频时长为5秒，输出视频前3秒有声，后2秒无声。


            支持输入的格式：


            公网URL：


            支持 HTTP 和 HTTPS 协议。


            示例值：`https://xxx/xxx.mp3`。


            临时URL：


            支持OSS协议，必须通过上传文件获取临时 URL。


            示例值：`oss://dashscope-instant/xxx/xxx.mp3`。


            **传入图像（type=first_frame或last_frame）**


            首帧或尾帧URL 或 Base64 编码数据。


            图片限制：

            - 格式：JPEG、JPG、PNG（无透明通道）、BMP、WEBP。

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

            - 宽高比：1:8～8:1。

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


            支持输入的格式：


            公网URL：


            支持 HTTP 或 HTTPS 协议。


            示例值：`https://xxx/xxx.png`。


            临时URL：


            支持OSS协议，必须通过上传文件获取临时 URL。


            示例值：`oss://dashscope-instant/xxx/xxx.png`。


            Base64 编码图片字符串：


            数据格式：data:{MIME_type};base64,{base64_data}。


            示例值：data:image/png;base64,GDU7MtCZzEbTbmRZ...... （此处省略以演示）。


            Base64 编码格式说明


            格式：data:{MIME_type};base64,{base64_data}。


            {base64_data}：图片文件的 Base64 编码字符串。


            {MIME_type}：图片的媒体类型，对应文件格式。


            图片格式与 MIME Type 对应关系：


            | 图片格式 | MIME Type |

            | --- | --- |

            | JPEG | image/jpeg |

            | JPG | image/jpeg |

            | PNG | image/png |

            | BMP | image/bmp |

            | WEBP | image/webp |
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````