Skip to main content

Wan2.7-Video Editing API Reference

The Wan2.7-Video Editing model supports multimodal input (text/image/video) and can perform instruction-based editing and video transfer tasks.

Related documentation: Guide

Applicable Scope

To ensure a successful call, make sure the model, endpoint URL, and API Key all belong to the same region. Cross-region calls will fail.
The example code in this document applies to the Singapore region.
Alibaba Cloud Model Studio provides dedicated workspace domains for the China (Beijing) and Singapore regions, which deliver superior performance and higher stability for inference requests. We recommend that you migrate to the new domains:
  • China (Beijing) region: migrate from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • Singapore region: migrate from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which you can view on the Workspace Details page of the Alibaba Cloud Model Studio console. The existing domains remain available.

HTTP Invocation

Video editing tasks are time-consuming (typically 1-5 minutes), so the API uses asynchronous calls. The entire process consists of two core steps: "create task -> poll for result", as follows:

Step 1: Create a task and obtain the task ID

  • Singapore
  • Beijing
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
When calling, replace {WorkspaceId} with your actual workspace ID.
  • After the task is created, use the task_id returned by the API to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks; just poll for the result.
  • For a beginner's guide, see Postman.

Request Parameters

Content-Typestring(required)Request content type. This parameter must be set to application/json.Authorizationstring(required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring(required)Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only and must be set to enable.
If this request header is missing, the following error is returned: "current user api does not support synchronous calls".
Request Body
model string (required)The model name.Example value: wan2.7-videoedit.input object (required)Basic input information, such as the prompt.

Property

prompt string (Optional)The text prompt. It describes the elements and visual features that you expect in the generated video.Supports both Chinese and English. Each Chinese character or letter counts as one character, and excess characters are automatically truncated.
  • wan2.7-videoedit: The length must not exceed 5000 characters.
Example value: Dress the character in cool, flashy clothes and add the hat from the reference image.negative_prompt string (Optional)The negative prompt, which describes the content you do not want to appear in the video, to constrain the video output.Supports both Chinese and English, with a length of no more than 500 characters; excess characters are automatically truncated.Example value: low resolution, fault, worst quality, low quality, incomplete, extra fingers, bad proportions, etc.media array (required)The list of media assets used to specify the reference materials (images and videos) required for video generation.Each element in the array is a media object that contains the type and url fields.

Property

type string (required)The media asset type. Valid values:
  • video: Required. The video to be edited.
  • reference_image: Optional. The reference image.
Asset limits:
  • There must be exactly one video.
  • A maximum of four reference images can be provided.
url string (required)The URL or Base64-encoded data of the media asset. Assets include videos and images.

Input video (type=video)

The URL of the video file to be edited.Video limits:
  • Format: mp4, mov.
  • Duration: 2 to 10 s.
  • Resolution: The width and height range from [240,4096] pixels.
  • Aspect ratio: 1:8 to 8:1.
  • File size: no more than 100MB.
Public URLs (HTTP or HTTPS protocol) are supported, for example: https://xxx/xxx.mp4.

Input image (type=reference_image)

The URL or Base64-encoded data of the reference image.Image limits:
  • Format: JPEG, JPG, PNG (transparent channels are not supported), BMP, WEBP.
  • Resolution: width and height in the range [240, 8000] pixels.
  • Aspect ratio: 1:8 to 8:1.
  • File size: no more than 20MB.
Supported input formats:
  1. Public URL:
  2. Base64-encoded string:
    • Data format: data:{MIME_type};base64,{base64_data}.
    • Example value: data:image/png;base64,GDU7MtCZzEbTbmRZ...... (example truncated, for demonstration only).
    Format: data:{MIME_type};base64,{base64_data}.
    • {base64_data}: the string obtained by Base64-encoding the image file.
    • {MIME_type}: the media type of the image, which must match the file format.

    Image format

    MIME Type

    JPEG

    image/jpeg

    JPG

    image/jpeg

    PNG

    image/png

    BMP

    image/bmp

    WEBP

    image/webp

parameters object (optional)Video processing parameters, such as setting the video resolution, setting the video duration, enabling intelligent prompt rewriting, adding a watermark, and so on.

Property

resolution string (optional)The resolution tier of the generated video, which controls the video clarity (total pixels).
  • wan2.7-videoedit: valid values: 720P, 1080P. The default value is 1080P.
ratio string (optional)The aspect ratio of the generated video.Effective logic:
  • If the ratio parameter is not specified: the video is generated with an aspect ratio close to that of the input video.
  • If the ratio parameter is specified: the video is generated according to the specified ratio.
Valid values:
  • 16:9
  • 9:16
  • 1:1
  • 4:3
  • 3:4
See the table below for the output video resolutions (width and height in pixels) corresponding to different aspect ratios.

Resolution tier

Aspect ratio

Output video resolution (width*height)

720P

16:9

1280*720

9:16

720*1280

1:1

960*960

4:3

1104*832

3:4

832*1104

1080P

16:9

1920*1080

9:16

1080*1920

1:1

1440*1440

4:3

1648*1248

3:4

1248*1648

duration integer (optional)The duration of the generated video, in seconds.Usage suggestion: configure this parameter only when you need to truncate the video. If you want the output video to have the same duration as the input video, no setting is required (or pass in the default value 0).Usage rules:
  • Default behavior: The default value is 0, which means the duration of the input video is used directly without truncation.
  • Truncation takes effect: When a specified duration is passed in, the system truncates the video from 0 seconds of the original video up to the length set by duration.
  • Value range: Integers between [2, 10] are supported.
audio_setting string (Optional)Video sound settings.
  • auto (default): The model makes an intelligent decision based on the prompt content. If the prompt involves sound descriptions, the audio may be regenerated; otherwise, the original sound of the input material may be retained.
  • origin: Forcefully retains the original sound of the input video without regeneration.
prompt_extendboolean (Optional)Whether to enable intelligent prompt rewriting. When enabled, a large model is used to intelligently rewrite the input prompt. It significantly improves the generation results for short prompts, but increases processing time.
  • true: Default value, intelligent rewriting enabled.
  • false: Intelligent rewriting disabled.
watermark boolean (Optional)Whether to add a watermark. The watermark is located in the lower-right corner of the video, with the fixed text "AI-generated".
  • false: Default value, no watermark added.
  • true: Add watermark.
Example value: false.seedinteger(Optional)Random number seed, with a value range of [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generation results, it is recommended to use a fixed seed value.Note that model generation is probabilistic, so even with the same seed, identical results for each generation are not guaranteed.
curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.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": "将整个画面转换为黏土风格",
        "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
    }
}'

Response parameters

output objectTask output information.

Property

task_id stringTask ID. Valid for queries within 24 hours.task_status stringStatus.

Enumerated values

  • PENDING: Task queuing
  • RUNNING: Task processing
  • SUCCEEDED: Task executed successfully
  • FAILED: Task execution failed
  • CANCELED: Task canceled
  • UNKNOWN: Task does not exist or status is unknown
request_idstringThe unique request identifier. It can be used for tracing request details and troubleshooting.codestringThe error code returned when a request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when a request fails. This parameter is not returned when the request succeeds. For details, see Error codes.
  • Successful response
  • Error response
Save the task_id for querying the task status and results.
{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

Step 2: Query results by task ID

  • Singapore
  • Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
When calling, replace {WorkspaceId} with your actual workspace ID.
  • Polling recommendations: Video generation takes several minutes. We recommend using a polling mechanism with a reasonable query interval (such as 15 seconds) to obtain the results.
  • Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
  • Result link: After the task succeeds, a video URL is returned, valid for 24 hours. We recommend downloading the video immediately after obtaining the URL and transferring it to permanent storage (such as Alibaba Cloud OSS).
  • task_id validity: 24 hours. After it expires, results can no longer be queried, and the API returns the task status UNKNOWN.

Request parameters

Request headers
Authorizationstring(required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.
URL path parameters
task_id string(Required)Task ID.
  • Query task results
Replace {task_id} entirely with the task_id value returned by the API in the previous step. The task_id query validity period is 24 hours. Also replace {WorkspaceId} with the actual workspace ID.
curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Response parameters

outputobjectTask output information.

Property

task_id stringTask ID. Valid for queries within 24 hours.task_status stringStatus.

Enumerated values

  • PENDING: Task queuing
  • RUNNING: Task processing
  • SUCCEEDED: Task executed successfully
  • FAILED: Task execution failed
  • CANCELED: Task canceled
  • UNKNOWN: Task does not exist or status is unknown
Status transitions during polling:
  • PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
  • The status on the first query is usually PENDING (Queuing) or RUNNING (Processing).
  • When the status changes to SUCCEEDED, the response contains the URL of the generated video.
  • If the status is FAILED, check the error message and try again.
  • If the status is CANCELED, the task has been canceled. To continue, submit the task again.
  • If the status is UNKNOWN, the task does not exist or the status is unknown. This may occur when the task_id does not exist or the 24-hour validity period has expired.
submit_time stringTask submission time. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringVideo URL. Returned only when task_status is SUCCEEDED.The link is valid for 24 hours, and you can download the video through this URL. The video format is MP4 (H.264 encoding).orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.codestringThe error code returned when a request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when a request fails. This parameter is not returned when the request succeeds. For details, see Error codes.
usage objectOutput statistics, counted only for successful results.

Property

input_video_duration floatThe duration of the input video, in seconds.output_video_duration floatThe duration of the output video, in seconds.duration floatThe total video duration, used for billing.Billing formula: duration=input_video_duration+output_video_duration.SR integerThe resolution tier of the output video. Example value: 720.video_count integerThe number of videos generated. Fixed at 1.
request_idstringThe unique request identifier. It can be used for tracing request details and troubleshooting.
  • Task execution succeeded
  • Task execution failed
  • Task query expired
The video URL is retained for only 24 hours and is automatically deleted after expiration. Save the generated video promptly.
{
    "request_id": "f16ae7e9-d518-92f8-a02c-xxxxxx",
    "output": {
        "task_id": "05e68c7e-850c-49e4-b866-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2026-04-03 00:08:03.576",
        "scheduled_time": "2026-04-03 00:08:13.408",
        "end_time": "2026-04-03 00:11:57.286",
        "orig_prompt": "将视频中女孩的衣服替换为图片中的衣服",
        "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?xxxx"
    },
    "usage": {
        "duration": 10.04,
        "input_video_duration": 5.02,
        "output_video_duration": 5.02,
        "video_count": 1,
        "SR": 720
    }
}

DashScope SDK call

The SDK parameter naming is basically consistent with that of the HTTP API, and the parameter structure is encapsulated based on language characteristics. Since video editing tasks are time-consuming (typically 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
The actual duration depends on the number of queued tasks and service execution status. Please wait patiently when obtaining the results.

Python SDK call

Make sure the DashScope Python SDK version is no lower than 2.0.1 before running the following code.If the version is too low, errors such as "url error, please check url!" may be triggered. Refer to Install SDK to update it.
Set region according to the region where the model is located (pass it in when constructing the Client; the region parameter values vary across regions):
  • Singapore
  • Beijing
region="ap-southeast-1"
When calling, replace {WorkspaceId} with your actual workspace ID.
  • Synchronous call
  • Asynchronous call
Request example
import base64
import mimetypes
import dashscope
import os
from dashscope import DashScopeError

# The following is the configuration for the Singapore (ap-southeast-1) region. Replace {WorkspaceId} with your actual workspace ID when calling. The region value varies by region.
client = dashscope.Client(
    # If you have not configured the environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
    # The API keys differ by region. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

# The format is data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
    mime_type, _ = mimetypes.guess_type(file_path)
    if not mime_type or not mime_type.startswith("image/"):
        raise ValueError("不支持或无法识别的图像格式")
    with open(file_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
    return f"data:{mime_type};base64,{encoded_string}"

# Reference image URL. The following three input methods are supported:

# [Method 1] Use a public image URL
reference_image_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"

# [Method 2] Use a local file (both absolute and relative paths are supported)
# Format: file:// + file path
# Example (absolute path):
# reference_image_url = "file://" + "/path/to/image.png"     # Linux/macOS
# reference_image_url = "file://" + "C:/path/to/image.png"    # Windows
# Example (relative path):
# reference_image_url = "file://" + "./image.png"             # Relative to the directory of the executing file

# [Method 3] Use Base64 encoding
# reference_image_url = encode_file("/path/to/image.png")

def sample_sync_call_videoedit():
    # generate is a one-step call (submits the task and waits for completion) that returns a completed Job.
    print('please wait...')
    try:
        job = client.videos.generate(
            model='wan2.7-videoedit',
            prompt='将视频中女孩的衣服替换为图片中的衣服',
            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": reference_image_url
                }
            ],
            resolution='720P',
            prompt_extend=True,
            watermark=True)
        print(job)
        print(job.video_url)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_sync_call_videoedit()
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
    "request_id": "d6c3c865-34e9-98a9-a53d-xxxxxx",
    "task_id": "1de7c853-755a-454a-91bc-xxxxxx",
    "status": "SUCCEEDED",
    "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx",
    "task_metrics": {
        "TOTAL": 1,
        "SUCCEEDED": 1,
        "FAILED": 0
    },
    "usage": {
        "video_count": 1,
        "duration": 10.08,
        "input_video_duration": 5.04,
        "output_video_duration": 5.04,
        "SR": 720
    }
}

Java SDK call

Make sure the DashScope Java SDK version is no lower than 2.22.14 before running the following code.If the version is too low, errors such as "url error, please check url!" may be triggered. Refer to Install SDK to update it.
Set Constants.baseHttpApiUrl according to the region where the model is located:
  • Singapore
  • Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
When calling, replace {WorkspaceId} with your actual workspace ID.
  • Synchronous call
  • Asynchronous call
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.

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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;

public class VideoEdit {

    static {
        // The following URL is for the Singapore region. When calling, replace {WorkspaceId} with your actual workspace ID. URLs vary by region.
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // If you have not configured the environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
    // API keys differ by region. Get an API key: https://www.alibabacloud.com/help/model-studio/get-api-key
    public static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    // The referenceImageUrl parameter supports the following three input methods.

    // Method 1: Use a public URL of an image.
    static String referenceImageUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png";

    // [Method 2] Use a local file (supports absolute and relative paths)
    // Format: file:// + file path
    // Example (absolute path):
    // static String referenceImageUrl = "file://" + "/path/to/image.png";     // Linux/macOS
    // static String referenceImageUrl = "file://" + "C:/path/to/image.png";   // Windows
    // Example (relative path):
    // static String referenceImageUrl = "file://" + "./image.png";             // Relative to the path of the current executable.

    // Method 3: Use Base64 encoding.
    // static String referenceImageUrl = encodeFile("/path/to/image.png");

    // The format is data:{MIME_type};base64,{base64_data}
    public static String encodeFile(String filePath) {
        Path path = Paths.get(filePath);
        if (!Files.exists(path)) {
            throw new IllegalArgumentException("文件不存在: " + filePath);
        }
        String mimeType = null;
        try {
            mimeType = Files.probeContentType(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("无法检测文件类型: " + filePath);
        }
        if (mimeType == null || !mimeType.startsWith("image/")) {
            throw new IllegalArgumentException("不支持或无法识别的图像格式");
        }
        byte[] fileBytes = null;
        try {
            fileBytes = Files.readAllBytes(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("无法读取文件内容: " + filePath);
        }
        String encodedString = Base64.getEncoder().encodeToString(fileBytes);
        return "data:" + mimeType + ";base64," + encodedString;
    }

    public static void videoEdit() throws ApiException, NoApiKeyException, InputRequiredException {
        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(referenceImageUrl)
                    .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("将视频中女孩的衣服替换为图片中的衣服")
                        .media(media)
                        .parameters(parameters)
                        .build();
        System.out.println("please wait...");
        VideoSynthesisResult result = vs.call(param);
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        try {
            videoEdit();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
    "request_id": "0a15ad3c-cde7-9f7e-b8d2-xxxxxx",
    "output": {
        "task_id": "0025d1e1-009a-4f53-9c27-xxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
        "orig_prompt": "将视频中女孩的衣服替换为图片中的衣服",
        "submit_time": "2026-04-10 17:21:01.719",
        "scheduled_time": "2026-04-10 17:21:13.182",
        "end_time": "2026-04-10 17:31:41.286"
    },
    "usage": {
        "video_count": 1,
        "duration": 10.08,
        "input_video_duration": 5.04,
        "output_video_duration": 5.04,
        "SR": "720"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

Error codes

If a model call fails and returns an error message, see Error codes for troubleshooting.