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
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.
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:
When calling, replace
When calling, replace
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.
Set
When calling, replace
Set
When calling, replace
If a model call fails and returns an error message, see Error codes for troubleshooting.
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.
- Select Model: Confirm the region of the model.
- Select URL: Select the endpoint URL of the corresponding region. HTTP URL or DashScope SDK URL is supported.
- Configure API Key: Obtain the API Key of the region, and then configure the API Key in environment variables.
The example code in this document applies to the Singapore region.
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{WorkspaceId} with your actual workspace ID.
- After the task is created, use the
task_idreturned 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 ParametersContent-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.Request Bodymodelstring (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.
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:
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:
Input image (type=reference_image) The URL or Base64-encoded data of the reference image.Image limits:
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).
string (optional)The aspect ratio of the generated video.Effective logic:
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:
string (Optional)Video sound settings.
boolean (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.
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".
integer(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. |
Response parametersoutputobjectTask output information.
Property task_id stringTask ID. Valid for queries within 24 hours.task_status stringStatus.
Enumerated values
stringThe 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. |
Save the task_id for querying the task status and results. |
Step 2: Query results by task ID
- Singapore
- Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{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 parametersRequest headersAuthorizationstring(required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameterstask_idstring(Required)Task ID. |
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. |
Response parametersoutputobjectTask output information.
Property task_id stringTask ID. Valid for queries within 24 hours.task_status stringStatus.
Enumerated values
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.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.stringThe unique request identifier. It can be used for tracing request details and troubleshooting. |
The video URL is retained for only 24 hours and is automatically deleted after expiration. Save the generated video promptly. |
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
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"{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 promptly.
Java SDK call
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";{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 promptly.