# Wan2.7 视频编辑

> 视频生成

提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。
Wan2.7-VideoEdit 支持基于指令的视频编辑和风格迁移。
视频编辑任务需要 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-videoedit接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `wan2.7-videoedit` 的视频编辑接口文档，说明如何提交生成任务、查询任务状态、读取视频结果以及处理错误。\n接口路径包括 `POST /v1/tasks/submit`、`GET /v1/tasks/status`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "该模型文档中使用的 ModelVerse API 端点。"
    }
  ],
  "tags": [
    {
      "name": "wan2.7-videoedit",
      "description": "Video editing asynchronous task operations."
    }
  ],
  "paths": {
    "/v1/tasks/submit": {
      "post": {
        "tags": [
          "wan2.7-videoedit"
        ],
        "operationId": "submitWan27VideoEditTask",
        "summary": "Wan2.7 视频编辑",
        "description": "提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。\nWan2.7-VideoEdit 支持基于指令的视频编辑和风格迁移。\n视频编辑任务需要 1-5 分钟，API 使用异步调用。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Wan27VideoEditSubmitRequest"
              },
              "examples": {
                "instructionOnly": {
                  "summary": "纯指令编辑（风格迁移）",
                  "value": {
                    "model": "wan2.7-videoedit",
                    "input": {
                      "prompt": "Convert the entire scene to a claymation style",
                      "media": [
                        {
                          "type": "video",
                          "url": "https://example.com/video.mp4"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "720P",
                      "prompt_extend": true,
                      "watermark": true
                    }
                  }
                },
                "withReferenceImage": {
                  "summary": "指令+参考图像编辑（换装）",
                  "value": {
                    "model": "wan2.7-videoedit",
                    "input": {
                      "prompt": "Replace the girl's clothes in the video with the clothes from the image",
                      "media": [
                        {
                          "type": "video",
                          "url": "https://example.com/video.mp4"
                        },
                        {
                          "type": "reference_image",
                          "url": "https://example.com/clothes.png"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "720P",
                      "prompt_extend": true,
                      "watermark": true
                    }
                  }
                },
                "withMultipleRefImages": {
                  "summary": "多参考图像编辑",
                  "value": {
                    "model": "wan2.7-videoedit",
                    "input": {
                      "prompt": "Replace the background with reference image 2 and the character clothes with reference image 3",
                      "media": [
                        {
                          "type": "video",
                          "url": "https://example.com/video.mp4"
                        },
                        {
                          "type": "reference_image",
                          "url": "https://example.com/bg.png"
                        },
                        {
                          "type": "reference_image",
                          "url": "https://example.com/clothes.png"
                        }
                      ]
                    },
                    "parameters": {
                      "resolution": "1080P",
                      "ratio": "16:9",
                      "duration": 5,
                      "audio_setting": "origin",
                      "prompt_extend": true,
                      "watermark": false
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务提交成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27VideoEditSubmitResponse"
                },
                "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/Wan27VideoEditErrorResponse"
                },
                "examples": {
                  "paramError": {
                    "$ref": "#/components/examples/Wan27VideoEditParamError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27VideoEditErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/Wan27VideoEditParamError"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/status": {
      "get": {
        "tags": [
          "wan2.7-videoedit"
        ],
        "operationId": "getWan27VideoEditTaskStatus",
        "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/Wan27VideoEditStatusResponse"
                },
                "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/Wan27VideoEditErrorResponse"
                },
                "examples": {
                  "paramError": {
                    "$ref": "#/components/examples/Wan27VideoEditParamError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wan27VideoEditErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/Wan27VideoEditParamError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "API Key 认证。请在请求头中携带 `Authorization: Bearer {your_api_key}`。\n"
      }
    },
    "schemas": {
      "Wan27VideoEditSubmitRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "wan2.7-videoedit",
            "description": "模型名称。此文档固定为 `wan2.7-videoedit`。"
          },
          "input": {
            "$ref": "#/components/schemas/Wan27VideoEditInput"
          },
          "parameters": {
            "$ref": "#/components/schemas/Wan27VideoEditParameters"
          }
        }
      },
      "Wan27VideoEditInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "media"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "description": "用于指导视频编辑的文本提示词。描述生成视频的期望元素和视觉特征。\n支持中文和英文。每个汉字、字母和标点符号都计为一个字符，最多 5000 字符。\n例如: \"Convert the entire scene to a claymation style\"\n例如: \"Replace the girl's clothes in the video with the clothes from the image\"\n"
          },
          "negative_prompt": {
            "type": "string",
            "description": "负面提示词，指定不希望在生成视频中出现的元素。\n支持中文和英文。最多 500 字符。\n例如: low resolution, error, worst quality, deformed, extra fingers\n"
          },
          "media": {
            "type": "array",
            "description": "媒体资源数组（视频和参考图像）。\n\n资源限制:\n- 只能有 1 个视频（type=video，必需）\n- 最多 4 张参考图像（type=reference_image，可选）\n",
            "items": {
              "$ref": "#/components/schemas/Wan27VideoEditMediaItem"
            }
          }
        }
      },
      "Wan27VideoEditMediaItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "url"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "媒体类型",
            "enum": [
              "video",
              "reference_image"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "媒体资源的 URL。\n\n视频（video）:\n- 格式: MP4, MOV\n- 时长: 2-10 秒\n- 分辨率: 宽和高在 240-4096 像素之间\n- 宽高比: 1:8 至 8:1\n- 文件大小: 最大 100 MB\n\n参考图像（reference_image）:\n- 格式: JPEG, JPG, PNG, BMP, WEBP\n- 分辨率: 宽和高在 240-8000 像素之间\n- 宽高比: 1:8 至 8:1\n- 文件大小: 最大 20 MB\n"
          }
        }
      },
      "Wan27VideoEditParameters": {
        "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- 720P 4:3 → 1104*832\n- 720P 3:4 → 832*1104\n- 1080P 16:9 → 1920*1080\n- 1080P 9:16 → 1080*1920\n- 1080P 1:1 → 1440*1440\n- 1080P 4:3 → 1648*1248\n- 1080P 3:4 → 1248*1648\n",
            "enum": [
              "16:9",
              "9:16",
              "1:1",
              "4:3",
              "3:4"
            ]
          },
          "duration": {
            "type": "integer",
            "description": "生成视频的时长，单位为秒。\n建议: 仅用于截断视频时使用。如要保持与输入视频相同时长，请省略此参数或传递默认值 0。\n取值规则:\n- 默认值 0 表示使用输入视频时长，不进行截断\n- 指定具体时长时，从原视频 0 秒处截断到指定时长\n取值范围: 2-10 秒\n",
            "minimum": 0,
            "maximum": 10,
            "default": 0
          },
          "audio_setting": {
            "type": "string",
            "description": "视频声音设置。\n- auto（默认）: 模型根据 prompt 智能决定音频。如 prompt 描述声音，可能生成新音频；否则保留原视频音频\n- origin: 强制保留输入视频的原始音频，不重新生成\n",
            "enum": [
              "auto",
              "origin"
            ],
            "default": "auto"
          },
          "prompt_extend": {
            "type": "boolean",
            "description": "是否启用智能提示词重写。开启后大模型重写输入提示词，\n显著改善短提示词的质量，但会增加处理时间。\n",
            "default": true
          },
          "watermark": {
            "type": "boolean",
            "description": "是否在生成视频右下角添加 \"AI Generated\" 水印。\n",
            "default": false
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2147483647,
            "description": "随机种子。取值范围 [0, 2147483647]。\n不指定时随机生成。固定种子可提高可重复性，但不保证完全相同的结果。\n"
          }
        }
      },
      "Wan27VideoEditSubmitResponse": {
        "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": "唯一请求标识。"
          }
        }
      },
      "Wan27VideoEditStatusResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "$ref": "#/components/schemas/Wan27VideoEditStatusOutput"
          },
          "usage": {
            "$ref": "#/components/schemas/Wan27VideoEditUsage"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "Wan27VideoEditStatusOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "task_id",
          "task_status"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "异步任务唯一标识。"
          },
          "task_status": {
            "$ref": "#/components/schemas/Wan27VideoEditTaskStatus"
          },
          "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": "任务失败时返回的错误信息。"
          }
        }
      },
      "Wan27VideoEditTaskStatus": {
        "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"
        ]
      },
      "Wan27VideoEditUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "duration": {
            "type": "integer",
            "description": "任务执行时长，单位为秒。"
          }
        }
      },
      "Wan27VideoEditErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Wan27VideoEditErrorObject"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识，如可用。"
          }
        }
      },
      "Wan27VideoEditErrorObject": {
        "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": {
      "Wan27VideoEditParamError": {
        "summary": "参数错误",
        "value": {
          "error": {
            "message": "Invalid param",
            "type": "invalid_request_error",
            "code": "InvalidParameter",
            "param": "input.media"
          },
          "request_id": "req_xxxxxxxxxxxxx"
        }
      }
    }
  }
}
```
