The Wanx 2.6 reference-to-video model supports multimodal input and can use people or objects as the main subject to generate videos of single-character performances or multi-character interactions.
Related documentation: User Guide
To ensure successful calls, make sure the model, Endpoint URL, and API Key all belong to the same region. Cross-region calls will fail.
Since video generation tasks take a long time (usually 1-5 minutes), the API uses asynchronous calls. The entire process consists of two core steps, "Create Task -> poll for results", as follows:
The SDK parameter naming is basically consistent with the HTTP API, and the parameter structure is encapsulated according to the characteristics of each language.
Since reference-to-video tasks take a long time (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous call modes.
Set
Set
If a model call fails and returns an error message, see Error codes for troubleshooting.
Scope
To ensure successful calls, 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 corresponding regional Endpoint URL. HTTP URLs are supported.
- Configure API Key: Select a region and obtain and configure an API Key, then configure the API Key in environment variables.
The sample code in this document applies to the Singapore region.
HTTP calls
Since video generation tasks take a long time (usually 1-5 minutes), the API uses asynchronous calls. The entire process consists of two core steps, "Create Task -> poll for results", as follows:
Step 1: Create a task and obtain the task ID
- Singapore
- Virginia
- Frankfurt
- Beijing
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesisWhen calling, replace {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 duplicate tasks; just poll for the result. - For a beginner's guide, see Postman.
Request ParametersRequest headersContent-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 calls only and must be set to enable.Request Bodymodelstring (Required)Model name. For the model list and prices, see Model pricing.Example value: wan2.6-r2v-flash.input object (Required)Basic input information, such as prompts.
Property prompt string (Required)Text prompt. Used to describe the elements and visual characteristics expected in the generated video.Both Chinese and English are supported. Each Chinese character, letter, or punctuation mark counts as one character, and any excess is automatically truncated.
string (Optional)Negative prompt, used to describe content that you do not want to appear in the video, constraining the video output.Both Chinese and English are supported; the length must not exceed 500 characters, and any excess is automatically truncated.Example value: low resolution, fault, worst quality, low quality, incomplete, extra fingers, bad proportions, etc.reference_urls array[string] (Required)An array of URLs of the uploaded reference files, supporting both videos and images. Used to extract the character appearance and voice (if any) to generate a video that matches the reference features.
Deprecated field reference_video_urls array[string]An array of URLs of the uploaded reference video files. Used to extract character appearance and voice (if any) to generate videos that match the reference features.
object (optional)Image processing parameters, such as setting the video resolution, enabling intelligent prompt rewriting, and adding a watermark.
Property size string (optional)Specifies the resolution of the generated video, in the format width*height. The default value and available enumeration values of this parameter depend on the model parameter, as follows:
integer (optional)The duration of the generated video, in seconds.
string (optional)Specifies the shot type of the generated video, that is, whether the video consists of one continuous shot or multiple switching shots.Parameter priority: shot_type > prompt. For example, if shot_type is set to "single", even if the prompt contains "generate a multi-shot video", the model still outputs a single-shot video.Available values:
When you want to strictly control the narrative structure of the video (for example, a single shot for product display or multiple shots for a story short film), you can specify it through this parameter. boolean (Optional)Supported models: wan2.6-r2v-flash.Whether to generate videos with audio.Available values:
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)The 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, there is no guarantee that each generation result will be exactly identical. |
Pass image and video URLs via reference_urls. Also set shot_type to multi to generate multi-shot videos. |
Response ParametersoutputobjectTask output information.
Property task_id stringTask ID. The query validity is 24 hours.task_status stringTask status.
Enumerated values
stringThe unique request identifier. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Save the task_id for querying task status and results. |
Step 2: Query results by task ID
- Singapore
- Virginia
- Frankfurt
- 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 results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result links: A video URL is returned after the task succeeds, 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. Once expired, results can no longer be queried, and the API returns the task status as
UNKNOWN.
Request parametersRequest headers (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 (Path parameters)task_idstring (Required)Task ID. |
Replace {task_id} entirely with the task_id value returned by the previous API call. The task_id can be queried within 24 hours. Also replace {WorkspaceId} with the actual workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id string (Required)Task ID.task_status stringTask status.
Enumerated values
stringTask submission time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.video_urlstringVideo URL. Returned only when task_status is SUCCEEDED.The URL is valid for 24 hours, and you can download the video via 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 the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.objectOutput information statistics. Only successful results are counted.
Property input_video_duration integerDuration of the input reference video, in seconds.output_video_duration integerDuration of the output video, in seconds.duration floatTotal video duration. Billing is calculated based on the duration.Calculation formula: duration = input_video_duration + output_video_duration.SR integerResolution tier of the generated video. Example value: 720.sizestringResolution of the generated video. The format is "widthheight". Example value: 1280720.video_count integerThe number of generated videos. Fixed to 1.stringThe unique request identifier. It can be used for request detail tracing and troubleshooting. |
The video URL is retained for only 24 hours and will be automatically cleared after it expires. Save the generated video in a timely manner. |
DashScope SDK calls
The SDK parameter naming is basically consistent with the HTTP API, and the parameter structure is encapsulated according to the characteristics of each language.
Since reference-to-video tasks take a long time (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous call modes.
The actual duration depends on the number of queued tasks and service execution conditions. Please wait patiently when obtaining the results.
Python SDK invocation
Set region based on the region where the model is located (pass it in when constructing the Client; the region value varies by region):
- Singapore
- Beijing
- United States
- Frankfurt
region="ap-southeast-1"When calling, replace {WorkspaceId} with your actual workspace ID.- Synchronous call
- Asynchronous call
A synchronous call blocks and waits until video generation is complete and returns the result.
Request example
Java SDK calls
Set baseHttpApiUrl based on the region where the model is located:
- Singapore
- Beijing
- Frankfurt
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
A synchronous call blocks and waits until video generation is complete and returns the result.