# Wan2.7 图生视频

> 视频生成

提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。
Wan2.7-I2V 支持从静态图像生成流畅、高质量的视频。
支持音频驱动:可通过提供音频文件让视频中的人物动作与音频节奏同步。

## 请求地址

`POST https://api.modelverse.cn/v1/tasks/submit`

## 请求体

## 响应

- **200** — 任务提交成功。
- **400** — 请求参数无效。
- **default** — 错误响应。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "wan2.7-i2v接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `wan2.7-i2v` 的图生视频接口文档，说明如何提交生成任务、查询任务状态、读取视频结果以及处理错误。\n接口路径包括 `POST /v1/tasks/submit`、`GET /v1/tasks/status`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "该模型文档中使用的 ModelVerse API 端点。"
    }
  ],
  "tags": [
    {
      "name": "wan2.7-i2v",
      "description": "Image-to-video asynchronous task operations."
    }
  ],
  "paths": {
    "/v1/tasks/submit": {
      "post": {
        "tags": [
          "wan2.7-i2v"
        ],
        "operationId": "submitWan27I2VTask",
        "summary": "Wan2.7 图生视频",
        "description": "提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。\nWan2.7-I2V 支持从静态图像生成流畅、高质量的视频。\n支持音频驱动:可通过提供音频文件让视频中的人物动作与音频节奏同步。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Wan27I2VSubmitRequest"
              },
              "examples": {
                "imageToVideo": {
                  "summary": "提交图生视频任务",
                  "value": {
                    "model": "wan2.7-i2v",
                    "input": {
                      "prompt": "A scene of urban fantasy art...",
                      "media": [
                        {
                          "type": "first_frame",
                          "url": "https://example.com/image.png"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "720P",
                      "duration": 10,
                      "prompt_extend": true,
                      "watermark": true
                    }
                  }
                },
                "audioDrivenVideo": {
                  "summary": "提交音频驱动视频任务",
                  "value": {
                    "model": "wan2.7-i2v",
                    "input": {
                      "prompt": "A boy sings an English rap song...",
                      "media": [
                        {
                          "type": "first_frame",
                          "url": "https://example.com/image.png"
                        },
                        {
                          "type": "driving_audio",
                          "url": "https://example.com/audio.mp3"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "720P",
                      "duration": 10,
                      "prompt_extend": true,
                      "watermark": true
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务提交成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27I2VSubmitResponse"
                },
                "examples": {
                  "submitted": {
                    "summary": "已提交任务",
                    "value": {
                      "output": {
                        "task_id": "task_xxxxxxxxxxxxx"
                      },
                      "request_id": "req_xxxxxxxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27I2VErrorResponse"
                },
                "examples": {
                  "paramError": {
                    "$ref": "#/components/examples/Wan27I2VParamError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27I2VErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/Wan27I2VParamError"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/status": {
      "get": {
        "tags": [
          "wan2.7-i2v"
        ],
        "operationId": "getWan27I2VTaskStatus",
        "summary": "Wan2.7 图生视频任务状态",
        "description": "查询异步任务状态。任务完成后，响应中会包含结果 URL、用量信息或错误信息。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "query",
            "required": true,
            "description": "由 `/v1/tasks/submit` 返回的异步任务标识符。",
            "schema": {
              "type": "string"
            },
            "examples": {
              "placeholder": {
                "summary": "源文档占位值",
                "value": "task_xxxxxxxxxxxxx"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务状态响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27I2VStatusResponse"
                },
                "examples": {
                  "success": {
                    "summary": "成功任务",
                    "value": {
                      "output": {
                        "task_id": "task_xxxxxxxxxxxxx",
                        "task_status": "SUCCEEDED",
                        "urls": [
                          "https://xxxxx/xxxx.mp4"
                        ],
                        "submit_time": 1756959000,
                        "finish_time": 1756959050
                      },
                      "usage": {
                        "duration": 5
                      },
                      "request_id": ""
                    }
                  },
                  "failure": {
                    "summary": "失败任务",
                    "value": {
                      "output": {
                        "task_id": "task_id",
                        "task_status": "Failure",
                        "submit_time": 1756959000,
                        "finish_time": 1756959019,
                        "error_message": "error_message"
                      },
                      "usage": {
                        "duration": 5
                      },
                      "request_id": ""
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27I2VErrorResponse"
                },
                "examples": {
                  "paramError": {
                    "$ref": "#/components/examples/Wan27I2VParamError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27I2VErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/Wan27I2VParamError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "API Key 认证。请在请求头中携带 `Authorization: Bearer {your_api_key}`。\n"
      }
    },
    "schemas": {
      "Wan27I2VSubmitRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "wan2.7-i2v",
            "description": "模型名称。此文档固定为 `wan2.7-i2v`。"
          },
          "input": {
            "$ref": "#/components/schemas/Wan27I2VInput"
          },
          "parameters": {
            "$ref": "#/components/schemas/Wan27I2VParameters"
          }
        }
      },
      "Wan27I2VInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "prompt",
          "media"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "description": "用于指导视频生成的文本提示词。建议详细描述期望的视频场景、动作和风格。\n"
          },
          "media": {
            "type": "array",
            "description": "媒体文件列表，包含首帧/尾帧图像、视频片段和可选的驱动音频。first_frame、last_frame 或 first_clip 必须至少提供一个。\n- first_frame:输入图片，视频的首帧。支持格式: JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP。宽度和高度必须在 [240, 8000] 像素范围内。宽高比: 1:8 到 8:1。文件大小: 最大 20 MB。支持输入格式: 公开 URL（HTTP 或 HTTPS 协议）或 Base64 编码的图片字符串，格式为 data:{MIME_type};base64,{base64_data}。\n- last_frame:输入图片，视频的尾帧。支持格式: JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP。宽度和高度必须在 [240, 8000] 像素范围内。宽高比: 1:8 到 8:1。文件大小: 最大 20 MB。支持输入格式: 公开 URL（HTTP 或 HTTPS 协议）或 Base64 编码的图片字符串，格式为 data:{MIME_type};base64,{base64_data}。\n- first_clip:输入视频，模型基于视频内容生成延续。支持格式: MP4、MOV。时长: 2秒到10秒。宽度和高度必须在 [240, 4096] 像素范围内。宽高比: 1:8 到 8:1。文件大小: 最大 100 MB。支持输入格式: 公开 URL（HTTP 或 HTTPS 协议）。\n  说明: duration 参数控制输出视频的最大总时长。例如，如果 duration=15 且输入视频为 3 秒，模型将生成 12 秒的延续，最终输出视频为 15 秒。\n- driving_audio（可选）:驱动音频文件 URL。提供音频时，模型将其用作口型同步和动作节奏的驱动源；不提供音频时，模型会自动生成匹配的背景音乐或音效。支持格式: WAV、MP3。时长: 2秒到30秒。文件大小: 最大15MB。支持输入格式: 公开 URL（HTTP 或 HTTPS 协议）。\n  截断规则: 如果音频时长大于视频时长（例如5秒），音频会自动截断为前5秒，其余部分被丢弃。如果音频时长小于视频时长，超出音频时长的视频部分将为静音。例如，音频时长3秒，视频时长5秒，则输出视频前3秒有声音，后2秒为静音。\n",
            "items": {
              "$ref": "#/components/schemas/Wan27I2VMediaItem"
            }
          }
        }
      },
      "Wan27I2VMediaItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "url"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "媒体类型",
            "enum": [
              "first_frame",
              "last_frame",
              "first_clip",
              "driving_audio"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "媒体文件的 URL"
          }
        }
      },
      "Wan27I2VParameters": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "resolution": {
            "type": "string",
            "description": "生成视频的分辨率。不同的分辨率会影响价格和生成质量。\n",
            "enum": [
              "720P",
              "1080P"
            ],
            "default": "720P"
          },
          "duration": {
            "type": "integer",
            "description": "生成视频的时长，单位为秒。\n",
            "enum": [
              5,
              10
            ]
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4294967295,
            "description": "随机种子。相同的种子配合相同的输入和参数会生成相似的结果。\n如果不指定，系统会随机生成一个种子。\n"
          },
          "prompt_extend": {
            "type": "boolean",
            "description": "是否启用智能提示词扩写。开启后系统会自动优化提示词，\n可能提高生成质量。\n",
            "default": true
          },
          "watermark": {
            "type": "boolean",
            "description": "是否在生成视频中添加水印。\n",
            "default": true
          }
        }
      },
      "Wan27I2VSubmitResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "task_id"
            ],
            "properties": {
              "task_id": {
                "type": "string",
                "description": "异步任务唯一标识。"
              }
            }
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "Wan27I2VStatusResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "$ref": "#/components/schemas/Wan27I2VStatusOutput"
          },
          "usage": {
            "$ref": "#/components/schemas/Wan27I2VUsage"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "Wan27I2VStatusOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "task_id",
          "task_status"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "异步任务唯一标识。"
          },
          "task_status": {
            "$ref": "#/components/schemas/Wan27I2VTaskStatus"
          },
          "urls": {
            "type": "array",
            "description": "视频结果 URL 列表。",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "submit_time": {
            "type": "integer",
            "format": "int64",
            "description": "任务提交时间戳（Unix 时间戳，秒级）。"
          },
          "finish_time": {
            "type": "integer",
            "format": "int64",
            "description": "任务完成时间戳（Unix 时间戳，秒级）。"
          },
          "error_message": {
            "type": "string",
            "description": "任务失败时返回的错误信息。"
          }
        }
      },
      "Wan27I2VTaskStatus": {
        "type": "string",
        "description": "异步任务状态。\n- Pending:等待处理\n- Running:正在处理\n- Success:任务成功完成\n- Failure:任务失败\n",
        "enum": [
          "Pending",
          "Running",
          "Success",
          "Failure"
        ]
      },
      "Wan27I2VUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "duration": {
            "type": "integer",
            "description": "任务执行时长，单位为秒。"
          }
        }
      },
      "Wan27I2VErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Wan27I2VErrorObject"
          }
        }
      },
      "Wan27I2VErrorObject": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "message",
          "type"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "错误信息。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "错误码。",
            "examples": [
              "param_error"
            ]
          },
          "param": {
            "type": [
              "string",
              "null"
            ],
            "description": "相关请求参数，如有。"
          }
        }
      }
    },
    "examples": {
      "Wan27I2VParamError": {
        "summary": "参数错误",
        "value": {
          "error": {
            "message": "Invalid param",
            "type": "invalid_request_error",
            "code": "param_error",
            "param": "input.media"
          }
        }
      }
    }
  }
}
```
