The Wan 2.7 video editing model accepts multimodal inputs (text, images, and videos) for instruction-based editing and style transfer .
Related documents: Guide
The model, endpoint URL, and API Key must all belong to the same region. Cross-region calls fail.
Video editing tasks typically take 1 to 5 minutes. The API uses asynchronous calls with two core steps: Create a task -> Poll for the result.
Replace
Replace
The SDK parameter naming is basically the same as that of the HTTP interface, and the parameter structure is encapsulated based on language characteristics.
Since video editing tasks take a long time to complete (usually 1 to 5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
Set
Replace
Set
Replace
If a model call fails, refer to Error codes for troubleshooting.
Applicability
The model, endpoint URL, and API Key must all belong to the same region. Cross-region calls fail.
- Select Model: Confirm the region that the model belongs to.
- Select URL: Select the Endpoint URL for the corresponding region. Both HTTP URLs and DashScope SDK URLs are supported.
- Configure API Key: Obtain the API Key for the region, and then configure the API Key as an environment variable.
Sample code in this topic uses China (Beijing).
HTTP
Video editing tasks typically take 1 to 5 minutes. The API uses asynchronous calls with two core steps: Create a task -> Poll for the result.
Step 1: Create a task
- Beijing
- Singapore
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- After the task is created successfully, use the
task_idreturned by the API to query the result. The task_id is valid for 24 hours. Do not create the task repeatedly; just poll for the result. - For beginner guides, see Postman.
Request parametersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.X-DashScope-Async string (Required)Asynchronous processing configuration parameter. HTTP requests support asynchronous calls only, so it must be set to enable.Request bodymodelstring (Required)The model name.Example value: wan2.7-videoedit.input object (Required)Input parameters, including the prompt.
Properties prompt string (Optional)Describes the desired elements and visual features in the generated video.Both Chinese and English are supported. Each Chinese character or English letter counts as one character. Longer text is automatically truncated.
string (Optional)A negative prompt that describes content to exclude from the video, which helps refine the output.Both Chinese and English are supported. The length cannot exceed 500 characters. Longer text is automatically truncated.Example value: low resolution, error, worst quality, low quality, disfigured, extra fingers, bad proportions.media array (Required)A list of media assets, such as images and videos, used as references for video generation.Each element in the array is a media object that contains the type and url fields.
Properties type string (Required)The type of the media asset. Valid values:
string (Required)The URL, Base64-encoded data, or Asset Center asset_id of the media asset. Assets include videos and images.
Input video (type=video) The URL or Asset Center asset_id of the video file to be edited.Video requirements:
Input image (type=reference_image) The URL, Base64-encoded data, or Asset Center asset_id of the reference image.Image requirements:
object (Optional)Parameters for video processing, such as resolution, duration, intelligent prompt rewriting, and watermarking.
Properties resolution string (Optional)The resolution tier of the generated video, which controls its clarity (total pixels).
string (Optional)The aspect ratio of the generated video.Behavior:
integer (Optional)The duration of the generated video, in seconds.Usage tips: Configure this parameter only when you need to "trim the video". If you want the output video to have the same duration as the input video, you do not need to set it (or pass in the default value 0).Usage rules:
string (Optional)Video sound settings.
boolean (Optional)Enables intelligent prompt rewriting. When enabled, a large model rewrites the input prompt, significantly improving generation quality for shorter prompts at the cost of increased processing time.
boolean (Optional)Whether to add a watermark. The watermark is in the lower-right corner of the video with the text "AI Generated".
integer (Optional)The random number seed must be an integer in the range [0, 2147483647].If not specified, a random seed is generated. A fixed seed improves reproducibility.Because model generation is probabilistic, the same seed does not guarantee identical results. |
Response parametersoutputobjectContains the task output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id, which is used to query the task status and result. |
Step 2: Query the result
- Beijing
- Singapore
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID.
- Polling tips: Video generation takes several minutes. We recommend using a polling mechanism with a reasonable query interval (for example, 15 seconds) to obtain the result.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: After the task succeeds, a video link is returned, which is valid for 24 hours. We recommend downloading the video immediately after you obtain the link and transferring it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After it expires, the result can no longer be queried, and the API returns the task status
UNKNOWN. - RPS limits: The default RPS of the query API is 20. For higher-frequency queries or event notifications, we recommend configuring asynchronous task callbacks.
- More operations: For operations such as querying tasks in batches or canceling tasks, see Managing asynchronous tasks.
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectContains the task output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. The format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. The format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringThe video URL. Returned only when task_status is SUCCEEDED.The link is valid for 24 hours, and you can download the video from this URL. The video format is MP4 (H.264 encoding).orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes.objectOutput statistics. Only successful results are counted.
Properties 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 generated videos. Fixed at 1.stringUnique request identifier for tracing and troubleshooting. |
The video URL is retained for only 24 hours and is automatically cleared after it expires. Save the generated video in a timely manner. |
Call via DashScope SDK
The SDK parameter naming is basically the same as that of the HTTP interface, and the parameter structure is encapsulated based on language characteristics.
Since video editing tasks take a long time to complete (usually 1 to 5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
The specific duration depends on the number of queued tasks and service execution status. Please wait patiently when obtaining the result.
Python SDK calls
Set region based on the region of the model (pass it in when constructing the Client; the region values vary by region):
- Beijing
- Singapore
region="cn-beijing"{WorkspaceId} with your actual workspace ID.
- Synchronous Call
- Asynchronous Call
Request example
Response example
The video_url is valid for 24 hours. Download the video in a timely manner.
Java SDK calls
Set Constants.baseHttpApiUrl based on the region of the model:
- Beijing
- Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID.
- Synchronous Call
- Asynchronous Call
Request example
Response example
The video_url is valid for 24 hours. Download the video in a timely manner.