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 parameter names in the SDK are mostly consistent with the HTTP API, but the parameter structure follows each language's conventions.
Video editing typically takes 1 to 5 minutes. The SDK handles the asynchronous HTTP call process internally, supporting both synchronous and asynchronous calls.
Set the base_http_api_url based on the service region:
Replace
Set the Constants.baseHttpApiUrl based on the service region:
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 a model: Confirm the region of the model.
- Select an endpoint URL: Choose the endpoint URL for the corresponding region. Both HTTP and DashScope SDK URLs are supported.
- Configure an API Key: Obtain an API Key for the region, then configure it as an environment variable.
Sample code in this topic uses Singapore.
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
- Singapore
- Beijing
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- After the task is created, use the returned
task_idto query the result. Thetask_idis valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result. - For guidance for beginners, see Call APIs with Postman or cURL.
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)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be 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.Recommendation: Only set this parameter to truncate the video. To keep the same duration as the input video, omit this parameter or pass the default value of 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.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the result
- Singapore
- Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID.
- Polling recommendation: Video generation takes several minutes. Use a polling mechanism with a reasonable interval, such as 15 seconds.
- Task state transition: PENDING → RUNNING → SUCCEEDED or FAILED.
- Result link: After a task succeeds, a video URL valid for 24 hours is returned. Download and save the video to permanent storage, such as OSS.
task_idvalidity: 24 hours. After this period, queries return the task status asUNKNOWN.
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 time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.video_url stringURL of the generated video. Returned only when task_status is SUCCEEDED.Valid for 24 hours. The video is in MP4 format with H.264 encoding.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectUsage statistics for billing. Billed only for successful tasks.
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, which is 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. This value is fixed at 1.stringUnique request identifier for tracing and troubleshooting. |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
DashScope SDK
The parameter names in the SDK are mostly consistent with the HTTP API, but the parameter structure follows each language's conventions.
Video editing typically takes 1 to 5 minutes. The SDK handles the asynchronous HTTP call process internally, supporting both synchronous and asynchronous calls.
Actual processing time depends on the number of queued tasks and service status. Wait for the result to complete.
Python SDK
Set the base_http_api_url based on the service region:
- Singapore
- China (Beijing)
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.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. Please download the video promptly.
Java SDK
Set the Constants.baseHttpApiUrl based on the service region:
- Singapore
- China (Beijing)
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.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. Please download the video promptly.