# Wan2.7 参考生成视频

> 视频生成

提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。
Wan2.7-R2V 支持从参考图像和视频生成高质量视频，保留角色外观和声音一致性。
视频生成任务需要 1-5 分钟，API 使用异步调用。

## 请求地址

`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-r2v接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `wan2.7-r2v` 的参考生成视频接口文档，说明如何提交生成任务、查询任务状态、读取视频结果以及处理错误。\n接口路径包括 `POST /v1/tasks/submit`、`GET /v1/tasks/status`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "该模型文档中使用的 ModelVerse API 端点。"
    }
  ],
  "tags": [
    {
      "name": "wan2.7-r2v",
      "description": "Reference-to-video asynchronous task operations."
    }
  ],
  "paths": {
    "/v1/tasks/submit": {
      "post": {
        "tags": [
          "wan2.7-r2v"
        ],
        "operationId": "submitWan27R2VTask",
        "summary": "Wan2.7 参考生成视频",
        "description": "提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。\nWan2.7-R2V 支持从参考图像和视频生成高质量视频，保留角色外观和声音一致性。\n视频生成任务需要 1-5 分钟，API 使用异步调用。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Wan27R2VSubmitRequest"
              },
              "examples": {
                "multiSubjectReference": {
                  "summary": "多主体参考（图像+视频+声音）",
                  "value": {
                    "model": "wan2.7-r2v",
                    "input": {
                      "prompt": "Video 1 holds Image 3 and plays a soothing country folk song...",
                      "media": [
                        {
                          "type": "reference_image",
                          "url": "https://example.com/girl.jpg",
                          "reference_voice": "https://example.com/girl-voice.mp3"
                        },
                        {
                          "type": "reference_video",
                          "url": "https://example.com/boy.mp4",
                          "reference_voice": "https://example.com/boy-voice.mp3"
                        },
                        {
                          "type": "reference_image",
                          "url": "https://example.com/object3.png"
                        },
                        {
                          "type": "reference_image",
                          "url": "https://example.com/background5.png"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "720P",
                      "ratio": "16:9",
                      "duration": 10,
                      "prompt_extend": false,
                      "watermark": true
                    }
                  }
                },
                "multiPanelStoryboard": {
                  "summary": "多格故事板参考",
                  "value": {
                    "model": "wan2.7-r2v",
                    "input": {
                      "prompt": "Based on the reference image, in the style of a 3D cartoon adventure movie...",
                      "media": [
                        {
                          "type": "reference_image",
                          "url": "https://example.com/storyboard.png"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "720P",
                      "ratio": "16:9",
                      "duration": 10,
                      "prompt_extend": false,
                      "watermark": true
                    }
                  }
                },
                "withFirstFrame": {
                  "summary": "首帧控制+参考图像",
                  "value": {
                    "model": "wan2.7-r2v",
                    "input": {
                      "prompt": "The cat from Image 1 is playing in the garden...",
                      "media": [
                        {
                          "type": "first_frame",
                          "url": "https://example.com/first-frame.png"
                        },
                        {
                          "type": "reference_image",
                          "url": "https://example.com/cat.jpg"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "1080P",
                      "ratio": "16:9",
                      "duration": 5,
                      "prompt_extend": true,
                      "watermark": false
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务提交成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27R2VSubmitResponse"
                },
                "examples": {
                  "submitted": {
                    "summary": "已提交任务",
                    "value": {
                      "output": {
                        "task_id": "task_xxxxxxxxxxxxx",
                        "task_status": "PENDING"
                      },
                      "request_id": "req_xxxxxxxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27R2VErrorResponse"
                },
                "examples": {
                  "paramError": {
                    "$ref": "#/components/examples/Wan27R2VParamError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27R2VErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/Wan27R2VParamError"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/status": {
      "get": {
        "tags": [
          "wan2.7-r2v"
        ],
        "operationId": "getWan27R2VTaskStatus",
        "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/Wan27R2VStatusResponse"
                },
                "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": "req_xxxxxxxxxxxxx"
                    }
                  },
                  "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/Wan27R2VErrorResponse"
                },
                "examples": {
                  "paramError": {
                    "$ref": "#/components/examples/Wan27R2VParamError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27R2VErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/Wan27R2VParamError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "API Key 认证。请在请求头中携带 `Authorization: Bearer {your_api_key}`。\n"
      }
    },
    "schemas": {
      "Wan27R2VSubmitRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "wan2.7-r2v",
            "description": "模型名称。此文档固定为 `wan2.7-r2v`。"
          },
          "input": {
            "$ref": "#/components/schemas/Wan27R2VInput"
          },
          "parameters": {
            "$ref": "#/components/schemas/Wan27R2VParameters"
          }
        }
      },
      "Wan27R2VInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "prompt",
          "media"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "description": "用于指导视频生成的文本提示词。描述期望的视频元素和视觉特征。\n支持中文和英文。每个汉字、字母和标点符号都计为一个字符，最多 5000 字符。\n\n引用标识符:\n- 图像: \"Image 1\", \"Image 2\"...（单词和数字间有空格，首字母大写）\n- 视频: \"Video 1\", \"Video 2\"...\n- 引用顺序必须与 media 数组中的顺序一致\n\n场景描述示例:\n- \"Image 1 is playing in Image 2\"（Image 1 是猫，Image 2 是房间）\n- \"The cat from Image 1 is playing in the room from Image 2\"\n\n多格故事板:\n当参考图像为多格故事板时，在提示词中按多镜头格式描述场景。\n不需要描述每一格，提供关键镜头即可，模型会自动识别分镜逻辑。\n"
          },
          "negative_prompt": {
            "type": "string",
            "description": "负面提示词，指定不希望在生成视频中出现的元素。\n支持中文和英文。最多 500 字符。\n例如: low resolution, error, worst quality, deformed, extra fingers, bad proportions\n"
          },
          "media": {
            "type": "array",
            "description": "媒体资源数组（图像、视频和音频），用作视觉和音频参考。\n数组顺序对应提示词中的引用标识符。\n\n资源限制:\n- 最多 1 张首帧图像（first_frame）\n- 至少 1 个参考图像或参考视频\n- 参考图像 + 参考视频 ≤ 5 个\n\n当用于主体时，参考资源必须只包含单个角色。\n",
            "items": {
              "$ref": "#/components/schemas/Wan27R2VMediaItem"
            }
          }
        }
      },
      "Wan27R2VMediaItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "url"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "媒体类型",
            "enum": [
              "reference_image",
              "reference_video",
              "first_frame"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "媒体资源的 URL。\n\n参考图像（reference_image）:\n- 格式: JPEG, JPG, PNG（不支持透明通道）, BMP, WEBP\n- 分辨率: 宽和高在 240-8000 像素之间\n- 宽高比: 1:8 至 8:1\n- 文件大小: 最大 20 MB\n- 支持 URL 或 Base64 编码\n\n参考视频（reference_video）:\n- 格式: MP4, MOV\n- 时长: 1-30 秒\n- 分辨率: 宽和高在 240-4096 像素之间\n- 宽高比: 1:8 至 8:1\n- 文件大小: 最大 100 MB\n\n首帧（first_frame）:\n- 生成视频从此帧开始\n- 通常包含主要角色（人物、动物或物体）\n- 可与主体参考联合控制\n"
          },
          "reference_voice": {
            "type": "string",
            "format": "uri",
            "description": "参考音频 URL，指定参考资源中主要角色的声音。\n与 reference_image 或 reference_video 配合使用。\n音频仅作为声音参考，不决定说话内容。\n\n音频逻辑:\n- 默认: 如 reference_video 包含音频且未指定 reference_voice，使用原视频音频\n- 优先级: 如同时提供 reference_video（带音频）和 reference_voice，reference_voice 优先\n\n音频限制:\n- 格式: WAV, MP3\n- 时长: 1-10 秒\n- 文件大小: 最大 15 MB\n"
          }
        }
      },
      "Wan27R2VParameters": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "resolution": {
            "type": "string",
            "description": "生成视频的分辨率等级。不同的分辨率会影响价格和生成质量。\n",
            "enum": [
              "720P",
              "1080P"
            ],
            "default": "1080P"
          },
          "ratio": {
            "type": "string",
            "description": "生成视频的宽高比。\n行为:\n- 未提供首帧图像: 视频使用指定的 ratio\n- 提供了首帧图像: ratio 参数被忽略，视频与首帧图像宽高比一致\n\n输出分辨率（宽*高）:\n- 720P 16:9 → 1280*720\n- 720P 9:16 → 720*1280\n- 720P 1:1 → 960*960\n- 1080P 16:9 → 1920*1080\n- 1080P 9:16 → 1080*1920\n- 1080P 1:1 → 1440*1440\n",
            "enum": [
              "16:9",
              "9:16",
              "1:1",
              "4:3",
              "3:4"
            ],
            "default": "16:9"
          },
          "duration": {
            "type": "integer",
            "description": "生成视频的时长，单位为秒。按秒计费。\n\n取值范围:\n- 参考材料包含视频: 2-10 秒\n- 参考材料不包含视频: 2-15 秒\n",
            "minimum": 2,
            "maximum": 15,
            "default": 5
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2147483647,
            "description": "随机种子。取值范围 [0, 2147483647]。\n不指定时随机生成。固定种子可提高可重复性，但不保证完全相同的结果。\n"
          },
          "prompt_extend": {
            "type": "boolean",
            "description": "是否启用智能提示词扩写。开启后大模型会在生成前重写输入提示词。\n显著改善短提示词的质量，但会增加处理时间。\n",
            "default": true
          },
          "watermark": {
            "type": "boolean",
            "description": "是否在生成视频右下角添加 \"AI Generated\" 水印。\n",
            "default": false
          }
        }
      },
      "Wan27R2VSubmitResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "task_id",
              "task_status"
            ],
            "properties": {
              "task_id": {
                "type": "string",
                "description": "异步任务唯一标识。有效期 24 小时。"
              },
              "task_status": {
                "type": "string",
                "description": "任务状态。",
                "enum": [
                  "PENDING",
                  "RUNNING",
                  "SUCCEEDED",
                  "FAILED",
                  "CANCELED",
                  "UNKNOWN"
                ]
              }
            }
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "Wan27R2VStatusResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "$ref": "#/components/schemas/Wan27R2VStatusOutput"
          },
          "usage": {
            "$ref": "#/components/schemas/Wan27R2VUsage"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "Wan27R2VStatusOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "task_id",
          "task_status"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "异步任务唯一标识。"
          },
          "task_status": {
            "$ref": "#/components/schemas/Wan27R2VTaskStatus"
          },
          "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": "任务失败时返回的错误信息。"
          }
        }
      },
      "Wan27R2VTaskStatus": {
        "type": "string",
        "description": "异步任务状态。\n- PENDING: 等待处理\n- RUNNING: 正在处理\n- SUCCEEDED: 任务成功完成\n- FAILED: 任务失败\n- CANCELED: 任务已取消\n- UNKNOWN: 任务不存在或状态未知\n状态流转: PENDING → RUNNING → SUCCEEDED 或 FAILED\n",
        "enum": [
          "PENDING",
          "RUNNING",
          "SUCCEEDED",
          "FAILED",
          "CANCELED",
          "UNKNOWN"
        ]
      },
      "Wan27R2VUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "duration": {
            "type": "integer",
            "description": "任务执行时长，单位为秒。"
          }
        }
      },
      "Wan27R2VErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Wan27R2VErrorObject"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识，如可用。"
          }
        }
      },
      "Wan27R2VErrorObject": {
        "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": [
              "InvalidApiKey",
              "InvalidParameter"
            ]
          },
          "param": {
            "type": [
              "string",
              "null"
            ],
            "description": "相关请求参数，如有。"
          }
        }
      }
    },
    "examples": {
      "Wan27R2VParamError": {
        "summary": "参数错误",
        "value": {
          "error": {
            "message": "Invalid param",
            "type": "invalid_request_error",
            "code": "InvalidParameter",
            "param": "input.media"
          },
          "request_id": "req_xxxxxxxxxxxxx"
        }
      }
    }
  }
}
```
