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

# Wan2.7 图生视频

> - WAN2.7 (wan2.7-image-to-video) 模型支持图生视频模式，支持多模态输入（图像/音频/视频）
- 通过 `generation_mode` 参数选择三种生成模式：
  - `first_frame`：**首帧生视频**——基于首帧图像生成视频，可选驱动音频
  - `first_last_frame`：**首尾帧生视频**——基于首帧+尾帧两张图像插值生成视频，可选驱动音频
  - `video_continuation`：**视频续写**——基于一段视频片段续写后续内容，可选尾帧图（不支持驱动音频）
- `generation_mode` 为可选参数（向后兼容），未传时将根据请求中的素材类型自动选择合适的模式
- 合法素材组合（非法组合将报错）：
  1. `image_start`（首帧）
  2. `image_start` + `audio_urls`（首帧 + 驱动音频）
  3. `image_start` + `image_end`（首尾帧）
  4. `image_start` + `image_end` + `audio_urls`（首尾帧 + 驱动音频）
  5. `video_urls`（视频续写）
  6. `video_urls` + `image_end`（视频续写 + 尾帧）
- 异步处理模式，使用返回的任务ID  [进行查询](/cn/api-manual/task-management/get-task-detail)
- 生成的视频链接，有效期为24小时，请尽快保存



## OpenAPI

````yaml cn/api-manual/video-series/wan2.7/wan2.7-image-to-video.json POST /v1/videos/generations
openapi: 3.1.0
info:
  title: wan2.7-image-to-video接口
  description: 使用WAN2.7模型进行图生视频，支持首帧/尾帧图、参考视频片段及音频驱动
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.evolink.ai
    description: 生产环境
security:
  - bearerAuth: []
paths:
  /v1/videos/generations:
    post:
      tags:
        - 视频生成
      summary: wan2.7-image-to-video接口
      description: >-
        - WAN2.7 (wan2.7-image-to-video) 模型支持图生视频模式，支持多模态输入（图像/音频/视频）

        - 通过 `generation_mode` 参数选择三种生成模式：
          - `first_frame`：**首帧生视频**——基于首帧图像生成视频，可选驱动音频
          - `first_last_frame`：**首尾帧生视频**——基于首帧+尾帧两张图像插值生成视频，可选驱动音频
          - `video_continuation`：**视频续写**——基于一段视频片段续写后续内容，可选尾帧图（不支持驱动音频）
        - `generation_mode` 为可选参数（向后兼容），未传时将根据请求中的素材类型自动选择合适的模式

        - 合法素材组合（非法组合将报错）：
          1. `image_start`（首帧）
          2. `image_start` + `audio_urls`（首帧 + 驱动音频）
          3. `image_start` + `image_end`（首尾帧）
          4. `image_start` + `image_end` + `audio_urls`（首尾帧 + 驱动音频）
          5. `video_urls`（视频续写）
          6. `video_urls` + `image_end`（视频续写 + 尾帧）
        - 异步处理模式，使用返回的任务ID 
        [进行查询](/cn/api-manual/task-management/get-task-detail)

        - 生成的视频链接，有效期为24小时，请尽快保存
      operationId: createWan27ImageToVideoGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Wan27ImageToVideoRequest'
            examples:
              first_frame:
                summary: 首帧生视频
                value:
                  model: wan2.7-image-to-video
                  generation_mode: first_frame
                  prompt: 一只猫在弹钢琴
                  image_start: https://example.com/first_frame.jpg
              first_frame_with_audio:
                summary: 首帧 + 驱动音频
                value:
                  model: wan2.7-image-to-video
                  generation_mode: first_frame
                  prompt: 一个少年正在演唱一首英文 rap
                  image_start: https://example.com/first_frame.jpg
                  audio_urls:
                    - https://example.com/rap.mp3
              first_last_frame:
                summary: 首尾帧生视频
                value:
                  model: wan2.7-image-to-video
                  generation_mode: first_last_frame
                  prompt: 镜头从平视角度逐渐升高至俯视
                  image_start: https://example.com/first_frame.png
                  image_end: https://example.com/last_frame.png
              video_continuation:
                summary: 视频续写
                value:
                  model: wan2.7-image-to-video
                  generation_mode: video_continuation
                  prompt: 一个女孩对镜自拍，自拍结束后背着书包出门
                  video_urls:
                    - https://example.com/clip.mp4
      responses:
        '200':
          description: 视频任务创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationResponse'
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: invalid_request
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: 未认证、Token无效或过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: unauthorized
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: 配额不足、需要充值
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: insufficient_quota
                  message: Insufficient quota. Please top up your account.
                  type: insufficient_quota
        '403':
          description: 无权限访问
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: model_access_denied
                  message: 'Token does not have access to model: wan2.7-image-to-video'
                  type: invalid_request_error
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: rate_limit_exceeded
                  message: Too many requests, please try again later
                  type: rate_limit_error
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: internal_error
                  message: Internal server error
                  type: api_error
components:
  schemas:
    Wan27ImageToVideoRequest:
      required:
        - model
      type: object
      properties:
        model:
          type: string
          description: 模型名称，固定为 `wan2.7-image-to-video`
          enum:
            - wan2.7-image-to-video
          example: wan2.7-image-to-video
        generation_mode:
          type: string
          description: >-
            生成模式，决定素材组合的合法性。**推荐显式指定**


            **取值说明：**

            - `first_frame`：首帧生视频。必传 `image_start`；可选 `audio_urls`；不接受
            `image_end` 与 `video_urls`

            - `first_last_frame`：首尾帧生视频。必传 `image_start` + `image_end`；可选
            `audio_urls`；不接受 `video_urls`

            - `video_continuation`：视频续写。必传 `video_urls[0]`；可选
            `image_end`（作为尾帧）；不接受 `image_start` 与 `audio_urls`


            **未传时的兼容行为：** 未传 `generation_mode`
            时，将根据请求中的素材类型自动选择合适的模式；建议显式指定以避免歧义
          enum:
            - first_frame
            - first_last_frame
            - video_continuation
          example: first_frame
        prompt:
          type: string
          description: 视频生成的文本提示词。支持中英文，每个汉字/字母占 1 个字符，超过部分会自动截断。最大长度 5000 字符
          maxLength: 5000
          example: 一只猫在弹钢琴
        negative_prompt:
          type: string
          description: 负面提示词，描述不希望在视频画面中出现的内容。支持中英文，最大长度 500 字符，超过部分会自动截断
          maxLength: 500
          example: 模糊, 低质量
        image_start:
          type: string
          format: uri
          description: |-
            首帧图片 URL

            **模式约束：**
            - `first_frame` 模式：**必传**
            - `first_last_frame` 模式：**必传**
            - `video_continuation` 模式：**禁止传入**

            **图像限制：**
            - 格式：JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP
            - 分辨率：宽和高的范围为 `[240, 8000]` 像素
            - 宽高比：1:8 ～ 8:1
            - 文件大小：不超过 `20MB`
          example: https://example.com/first_frame.jpg
        image_end:
          type: string
          format: uri
          description: |-
            尾帧图片 URL

            **模式约束：**
            - `first_last_frame` 模式：**必传**
            - `video_continuation` 模式：可选（作为视频续写的目标尾帧）
            - `first_frame` 模式：**禁止传入**（如需首尾帧，请使用 `first_last_frame`）

            **图像限制：**
            - 格式：JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP
            - 分辨率：宽和高的范围为 `[240, 8000]` 像素
            - 宽高比：1:8 ～ 8:1
            - 文件大小：不超过 `20MB`
          example: https://example.com/last_frame.jpg
        video_urls:
          type: array
          items:
            type: string
            format: uri
          description: |-
            视频续写 URL 数组，**仅支持 1 个元素**

            **模式约束：**
            - `video_continuation` 模式：**必传**
            - `first_frame` / `first_last_frame` 模式：**禁止传入**
            - 不能与 `audio_urls` 同时使用

            **视频限制：**
            - 格式：mp4、mov
            - 时长：`2 ~ 10` 秒（输入片段本身长度）
            - 分辨率：宽和高的范围为 `[240, 4096]` 像素
            - 宽高比：1:8 ～ 8:1
            - 文件大小：不超过 `100MB`

            **续写时长规则：**
            - `duration` 参数表示**最终输出视频的总时长**（包含原始输入片段 + 模型续写部分）
            - 模型续写的部分 = `duration` − 输入视频时长
            - `duration` 必须 ≥ 输入视频时长
            - 计费按最终输出视频总时长（即 `duration`）结算

            **示例：**

            | 输入视频时长 | duration | 续写生成 | 最终输出 | 计费时长 |
            | --- | --- | --- | --- | --- |
            | 3 秒 | 15 | 12 秒 | 15 秒 | 15 秒 |
            | 5 秒 | 10 | 5 秒 | 10 秒 | 10 秒 |
            | 8 秒 | 8 | 0 秒（仅原片输出） | 8 秒 | 8 秒 |
          example:
            - https://example.com/clip.mp4
        audio_urls:
          type: array
          items:
            type: string
            format: uri
          minItems: 1
          maxItems: 1
          description: |-
            驱动音频文件 URL 数组。**当前仅支持 1 个元素**。模型将以该音频为驱动源生成视频（如口型同步、动作卡点等）

            **模式约束：**
            - `first_frame` 模式：可选
            - `first_last_frame` 模式：可选
            - `video_continuation` 模式：**禁止传入**（不能与 `video_urls` 同时使用）

            **格式要求：**
            - 支持格式：`wav`、`mp3`
            - 时长范围：`2 ~ 30` 秒
            - 文件大小：不超过 `15MB`

            **截断处理：**
            - 若音频长度超过 `duration` 值，自动截取前 N 秒，其余部分丢弃
            - 若音频长度不足视频时长，超出音频长度部分为无声视频。例如：音频为 3 秒、视频时长为 5 秒，输出视频前 3 秒有声、后 2 秒无声
          example:
            - https://example.com/audio.mp3
        quality:
          type: string
          description: |-
            视频清晰度，默认为`720p`

            **说明：**
            - `720p`: 标准清晰度，标准价格，此为默认值
            - `1080p`: 高清晰度，价格会提升
          enum:
            - 720p
            - 1080p
          default: 720p
          example: 720p
        duration:
          type: number
          description: |-
            视频时长（秒），整数，范围 `2 ~ 15`，默认 `5`

            **含义说明：**
            - `first_frame` / `first_last_frame` 模式：表示**生成视频的总时长**
            - `video_continuation` 模式：表示**最终输出视频的总时长**（= 原始输入片段 + 模型续写部分）

            **`video_continuation` 模式额外约束：**
            - `duration` 必须 **≥ 输入视频时长**（否则报错）
            - 续写生成的时长 = `duration` − 输入视频时长
            - 当 `duration` = 输入视频时长时，不进行续写，仅原样输出输入片段
            - 详见 `video_urls` 字段中的续写时长规则与示例

            **计费说明：** 实际扣费以生成视频的秒数为准
          minimum: 2
          maximum: 15
          default: 5
          example: 5
        seed:
          type: integer
          description: |-
            随机种子，默认随机

            **说明：**
            - 取值范围：`1` ~ `2147483647`
            - 固定 seed 可在调试 prompt 时降低参数变化的干扰，提升结果可复现性
          minimum: 1
          maximum: 2147483647
          example: 42
        prompt_extend:
          type: boolean
          description: |-
            是否开启prompt智能改写，开启后将使用大模型优化正向提示词，对描述性不足、较为简单的prompt提升效果较明显。

            **注意：** 默认值为 `false`，不传或传 `false` 时不会触发改写，如需开启请显式传 `true`
          default: false
          example: false
        callback_url:
          type: string
          description: |-
            任务完成后的HTTPS回调地址

            **回调时机：**
            - 任务完成（completed）、失败（failed）或取消（cancelled）时触发
            - 在计费确认完成后发送

            **安全限制：**
            - 仅支持HTTPS协议
            - 禁止回调到内网IP地址（127.0.0.1、10.x.x.x、172.16-31.x.x、192.168.x.x等）
            - URL长度不超过`2048`字符

            **回调机制：**
            - 超时时间：`10`秒
            - 失败后最多重试`3`次（会分别在失败的`1`秒/`2`秒/`4`秒后进行重试）
            - 回调响应体格式与任务查询接口返回的格式一致
            - 回调地址若返回2xx状态码视为成功，其他状态码会触发重试
          format: uri
          example: https://your-domain.com/webhooks/video-task-completed
    VideoGenerationResponse:
      type: object
      properties:
        created:
          type: integer
          description: 任务创建时间戳
          example: 1757169743
        id:
          type: string
          description: 任务ID
          example: task-unified-1757169743-7cvnl5zw
        model:
          type: string
          description: 实际使用的模型名称
          example: wan2.7-image-to-video
        object:
          type: string
          enum:
            - video.generation.task
          description: 任务的具体类型
        progress:
          type: integer
          description: 任务进度百分比 (0-100)
          minimum: 0
          maximum: 100
          example: 0
        status:
          type: string
          description: 任务状态
          enum:
            - pending
            - processing
            - completed
            - failed
          example: pending
        task_info:
          $ref: '#/components/schemas/VideoTaskInfo'
          description: 视频任务详细信息
        type:
          type: string
          enum:
            - text
            - image
            - audio
            - video
          description: 任务的输出类型
          example: video
        usage:
          $ref: '#/components/schemas/Usage'
          description: 使用量和计费信息
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: 错误代码标识符
            message:
              type: string
              description: 错误描述信息
            type:
              type: string
              description: 错误类型
    VideoTaskInfo:
      type: object
      properties:
        can_cancel:
          type: boolean
          description: 任务是否可以取消
          example: true
        estimated_time:
          type: integer
          description: 预估完成时间（秒）
          minimum: 0
          example: 120
    Usage:
      type: object
      description: 使用量和计费信息
      properties:
        billing_rule:
          type: string
          description: 计费规则
          enum:
            - per_call
            - per_token
            - per_second
          example: per_call
        credits_reserved:
          type: number
          description: 预估消耗积分数
          minimum: 0
          example: 5
        user_group:
          type: string
          description: 用户组类别
          enum:
            - default
            - vip
          example: default
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |-
        ##所有接口均需要使用Bearer Token进行认证##

        **获取 API Key ：**

        访问 [API Key 管理页面](https://evolink.ai/dashboard/keys) 获取您的 API Key

        **使用时在请求头中添加：**
        ```
        Authorization: Bearer YOUR_API_KEY
        ```

````