Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗
Wan 2.7 -- Edite um vídeo
Enviar tarefa de edição de vídeo (wan2.7)
Edite vídeos em até 1080P usando prompts de texto e imagens de referência opcionais – altere estilos, substitua objetos ou transfira conteúdo de imagens de referência para o vídeo de origem.
OpenAPI
openapi: 3.1.0
info:
title: Wan 2.7 Video Editing API
description: Edit videos using the Wan 2.7 model. Supports multimodal inputs such as text, images, and videos for video editing. Submit a task asynchronously, then poll `GET /tasks/{task_id}` for the result.
version: 1.0.0
servers:
- url: https://maas.qwencloudapi.com/api/v1
description: Singapore
security:
- BearerAuth: []
paths:
/services/aigc/video-generation/video-synthesis:
post:
operationId: createWan27VideoEditing
summary: Create video editing task
description: Submit a video editing task. Returns a `task_id` for polling. Requires DashScope Python SDK 1.25.16 or later and Java SDK 2.22.14 or later.
parameters:
- name: X-DashScope-Async
in: header
required: true
description: Must be set to `enable` for asynchronous task submission.
schema:
type: string
enum:
- enable
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Wan27VideoEditingRequest"
responses:
"200":
description: Task submitted successfully
content:
application/json:
schema:
$ref: "#/components/schemas/AsyncTaskSubmitResponse"
"400":
description: Invalid request parameters
content:
application/json:
schema:
$ref: "#/components/schemas/DashScopeErrorResponse"
x-codeSamples:
- lang: curl
label: cURL - Change video style
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.7-videoedit",
"input": {
"prompt": "Convert the entire scene to a claymation style",
"media": [
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/ldnfdf/wan2.7-videoedit-style-change.mp4"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": true,
"watermark": true
}
}'
- lang: curl
label: cURL - Video editing with reference image
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"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://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": true,
"watermark": true
}
}'
- lang: python
label: Python - Synchronous call
source: |-
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_sync_call_videoedit():
print('Please wait...')
rsp = VideoSynthesis.call(
api_key=api_key,
model='wan2.7-videoedit',
prompt='Replace the clothes of the girl in the video with the clothes from the image.',
media=[
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
}
],
resolution='720P',
prompt_extend=True,
watermark=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_sync_call_videoedit()
- lang: python
label: Python - Asynchronous call
source: |-
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call_videoedit():
rsp = VideoSynthesis.async_call(
api_key=api_key,
model='wan2.7-videoedit',
prompt='Replace the clothes of the girl in the video with the clothes from the image.',
media=[
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
}
],
resolution='720P',
prompt_extend=True,
watermark=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("task_id: %s" % rsp.output.task_id)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# Wait for the task to complete
rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_async_call_videoedit()
- lang: java
label: Java - Synchronous call
source: |-
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.*;
public class VideoEdit {
static {
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
public static void main(String[] args) {
try {
VideoSynthesis vs = new VideoSynthesis();
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>() {{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4")
.type("video").build());
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png")
.type("reference_image").build());
}};
Map<String, Object> parameters = new HashMap<>();
parameters.put("resolution", "720P");
parameters.put("prompt_extend", true);
parameters.put("watermark", true);
VideoSynthesisParam param = VideoSynthesisParam.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model("wan2.7-videoedit")
.prompt("Replace the clothes of the girl in the video with the clothes from the image.")
.media(media)
.parameters(parameters)
.build();
System.out.println("Please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
}
}
- lang: java
label: Java - Asynchronous call
source: |-
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.*;
public class VideoEdit {
static {
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
public static void main(String[] args) {
try {
String apiKey = System.getenv("DASHSCOPE_API_KEY");
VideoSynthesis vs = new VideoSynthesis();
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>() {{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4")
.type("video").build());
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png")
.type("reference_image").build());
}};
Map<String, Object> parameters = new HashMap<>();
parameters.put("resolution", "720P");
parameters.put("prompt_extend", true);
parameters.put("watermark", true);
VideoSynthesisParam param = VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-videoedit")
.prompt("Replace the clothes of the girl in the video with the clothes from the image.")
.media(media)
.parameters(parameters)
.build();
// Async call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("Please wait...");
// Wait for result
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
}
}
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: DashScope API Key. Get one from the [QwenCloud console](https://home.qwencloud.com/api-keys).
schemas:
Wan27VideoEditingRequest:
type: object
required:
- model
- input
properties:
model:
type: string
description: "Model identifier. Fixed value: `wan2.7-videoedit`."
enum:
- wan2.7-videoedit
example: wan2.7-videoedit
input:
type: object
required:
- media
description: Specifies input parameters, such as the prompt.
properties:
prompt:
type: string
description: A text prompt that describes the desired elements and visual features in the generated video. Supports Chinese and English, up to 5,000 characters (auto-truncated if exceeded).
example: Convert the entire scene to a claymation style
negative_prompt:
type: string
description: Describe what to exclude from the video (e.g., `low quality, blurry, extra fingers`). Supports Chinese and English, up to 500 characters (auto-truncated if exceeded).
example: low resolution, error, worst quality, low quality, incomplete, extra fingers, poor proportions
media:
type: array
description: |-
Media materials for editing. Each element has `type` and `url` fields.
- **video** (required; you can provide only one video): The video to edit. Format: MP4, MOV. Duration: 2-10 seconds. Resolution: width and height in [240, 4096] pixels. Aspect ratio: 1:8 to 8:1. Max file size: 100 MB. HTTP/HTTPS URLs only.
- **reference_image** (optional; you can provide a maximum of four reference images): Reference images for style or content transfer. Format: JPEG, JPG, PNG (no alpha channel), BMP, WEBP. Resolution: width and height in [240, 8000] pixels. Aspect ratio: 1:8 to 8:1. Max file size: 20 MB. Supports HTTP/HTTPS URLs and Base64-encoded data (`data:{MIME_type};base64,{base64_data}`).
items:
type: object
required:
- type
- url
properties:
type:
type: string
description: |-
Media type.
- `video`: The video to edit (required, max 1).
- `reference_image`: A reference image (optional, max 4).
enum:
- video
- reference_image
url:
type: string
description: |-
URL or Base64-encoded data.
**For video** (`type=video`): Public URL (HTTP/HTTPS).
**For image** (`type=reference_image`): Public URL (HTTP/HTTPS) or Base64 string in the format `data:{MIME_type};base64,{base64_data}`. Supported MIME types: `image/jpeg`, `image/png`, `image/bmp`, `image/webp`.
parameters:
$ref: "#/components/schemas/Wan27VideoEditingParameters"
Wan27VideoEditingParameters:
type: object
description: Video editing parameters.
properties:
resolution:
type: string
description: |-
Video clarity tier. Higher resolution costs more.
Actual output dimensions depend on `ratio`:
- **720P**: 16:9=1280x720, 9:16=720x1280, 1:1=960x960, 4:3=1104x832, 3:4=832x1104
- **1080P**: 16:9=1920x1080, 9:16=1080x1920, 1:1=1440x1440, 4:3=1648x1248, 3:4=1248x1648
enum:
- 720P
- 1080P
default: 1080P
ratio:
type: string
description: Aspect ratio of the output video. If omitted, uses the input video's aspect ratio.
enum:
- 16:9
- 9:16
- 1:1
- 4:3
- 3:4
duration:
type: integer
description: "Output video duration in seconds. `0` (default): use the input video's full duration without truncation. `2`-`10`: truncate the input video to this length."
maximum: 10
minimum: 0
default: 0
audio_setting:
type: string
description: |-
Audio handling for the output video.
- `auto` (default): The model decides based on `prompt`. If the prompt describes sound, audio may be regenerated; otherwise the original audio is kept.
- `origin`: Always keep the original audio without regeneration.
enum:
- auto
- origin
default: auto
prompt_extend:
type: boolean
description: Rewrite the prompt using a Large Language Model before generation. Improves results for short or vague prompts but adds latency. Set to `false` to use your prompt verbatim.
default: true
watermark:
type: boolean
description: Add an "AI Generated" watermark in the lower-right corner.
default: false
seed:
type: integer
description: Seed for reproducible results. Same seed + same parameters produces similar (not identical) output.
minimum: 0
maximum: 2147483647
AsyncTaskSubmitResponse:
type: object
description: Response from an asynchronous task submission.
properties:
request_id:
type: string
description: Unique request identifier for tracing and troubleshooting.
example: 4909100c-7b5a-9f92-bfe5-xxxxxx
output:
type: object
properties:
task_id:
type: string
description: Task ID for polling status. Use with `GET /tasks/{task_id}`.
example: 0385dc79-5ff8-4d82-bcb6-xxxxxx
task_status:
type: string
description: Initial task status, typically `PENDING`.
enum:
- PENDING
- RUNNING
- SUCCEEDED
- FAILED
Wan27VideoEditingTaskStatusResponse:
type: object
description: Response from querying the status of a wan2.7 video editing task.
properties:
request_id:
type: string
description: Unique request identifier for tracing and troubleshooting.
example: f16ae7e9-d518-92f8-a02c-xxxxxx
output:
type: object
properties:
task_id:
type: string
description: Task ID. Queryable for 24 hours after submission.
example: 05e68c7e-850c-49e4-b866-xxxxxx
task_status:
type: string
description: "Task lifecycle: `PENDING` -> `RUNNING` -> `SUCCEEDED` or `FAILED`. `CANCELED` if manually stopped. `UNKNOWN` if expired."
enum:
- PENDING
- RUNNING
- SUCCEEDED
- FAILED
- CANCELED
- UNKNOWN
submit_time:
type: string
description: When the task was submitted (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`).
example: 2026-04-03 00:08:03.576
scheduled_time:
type: string
description: When the task started running (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`).
example: 2026-04-03 00:08:13.408
end_time:
type: string
description: When the task finished (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`). Only present for `SUCCEEDED` or `FAILED` tasks.
example: 2026-04-03 00:11:57.286
orig_prompt:
type: string
description: Your original prompt text before any rewriting by `prompt_extend`.
video_url:
type: string
format: uri
description: URL of the generated video (MP4, H.264 encoding). Only present when `task_status` is `SUCCEEDED`. **Valid for 24 hours** -- download promptly.
example: https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?xxxx
code:
type: string
description: Error code. Only present when `task_status` is `FAILED`.
message:
type: string
description: Error message. Only present when `task_status` is `FAILED`.
usage:
type: object
description: Resource consumption. Only present when `task_status` is `SUCCEEDED`.
properties:
input_video_duration:
type: number
description: Input video duration in seconds.
output_video_duration:
type: number
description: Output video duration in seconds.
duration:
type: number
description: "Billable video duration in seconds. Formula: `input_video_duration + output_video_duration`."
SR:
type: integer
description: Resolution tier of the output video (e.g., `720`).
video_count:
type: integer
description: "Number of videos generated. Fixed value: `1`."
DashScopeErrorResponse:
type: object
description: DashScope API error response.
properties:
request_id:
type: string
description: Unique request identifier for tracing and support.
code:
type: string
description: Error code (e.g., `InvalidParameter`, `Throttling`, `Unauthorized`).
example: InvalidParameter
message:
type: string
description: Human-readable error message.
example: Invalid model name