The Wan reference-to-video model accepts multimodal input and generates single-character or multi-character interaction videos using people or objects as protagonists.
See also: User guide
Availability
The model, endpoint URL, and API key must belong to the same region. Cross-region calls will fail.
- Select a model: Confirm the region of the model.
- Select a URL: Use the endpoint URL for the corresponding region. HTTP URLs are supported.
- Configure API key: Select a region and Obtain an API key, then Configure API key as an environment variable.
NoteThe sample code in this topic applies to the Singapore region.
ImportantAlibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing) and Singapore regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
- China (Beijing): from
https://dashscope.aliyuncs.comtohttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com - Singapore: from
https://dashscope-intl.aliyuncs.comtohttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.
HTTP
ImportantThis is a legacy API that only supports wan2.6 models.
Video generation tasks typically take 1–5 minutes. The API uses asynchronous calls with two steps: "create a task -> poll for the result". Details are as follows:
Step 1: Create a task
Singapore
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
US (Virginia)
POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Frankfurt
POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
China (Beijing)
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
Note
- 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 parametersHeadersContent-Type The content type of the request. Must be Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. X-DashScope-Async Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be ImportantIf this request header is missing, the error "current user api does not support synchronous calls" is returned. Request bodymodel The model to use. See Model pricing for available models and pricing. Example: wan2.6-r2v-flash. input Input parameters such as the prompt. parameters Video generation parameters such as resolution, prompt rewriting, and watermark. | Multi-character interaction (reference images and videos)Pass image and video URLs through Multi-character interaction (reference videos)Pass multiple video URLs through Single characterPass a single video URL through Generate silent videoOnly To generate silent video, you must explicitly set |
Response parametersoutput Task output. request_id Unique request identifier for tracing and troubleshooting. code Error code. Returned only for failed requests. See Error codes. message Detailed error message. Returned only for failed requests. See Error codes. | Successful responseSave the Error responseTask creation failed. See Error codes. |
Step 2: Retrieve task result
Singapore
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
US (Virginia)
GET https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Frankfurt
GET https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
China (Beijing)
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
Note
- 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 parametersHeadersAuthorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. Path parameterstask_id The ID of the task. | Retrieve task resultReplace |
Response parametersoutput Task output. usage Usage statistics. Only counts successful results. request_id Unique request identifier for tracing and troubleshooting. | Task succeededVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. Task failedWhen a task fails, Task expiredThe |
DashScope SDK
SDK parameters follow the same naming conventions as the HTTP API, with language-specific wrappers.
Reference-to-video tasks typically take 1–5 minutes. The SDK wraps the HTTP asynchronous workflow and supports both synchronous and asynchronous calls.
Actual processing time depends on the task queue and server load.
Python
ImportantMake sure your DashScope Python SDK version is 2.0.1 or later before running the following code.
An outdated SDK version may cause errors such as "url error, please check url!". See Install the SDK to update.
Set region based on the model's region (passed in when constructing the Client; the region value varies by region):
Singapore
region="ap-southeast-1"
Replace {WorkspaceId} with your actual workspace ID.
China (Beijing)
region="cn-beijing"
Replace {WorkspaceId} with your actual workspace ID.
Frankfurt
region="eu-central-1"
Replace {WorkspaceId} with your actual workspace ID.
Synchronous
Synchronous calls block until video generation completes and the result is returned.
Request example
import dashscope
import os
from dashscope.v2 import DashScopeError
# The following is the configuration for the Singapore (ap-southeast-1) region. Replace {WorkspaceId} with your Model Studio workspace ID. The region value varies by region.
client = dashscope.Client(
# If DASHSCOPE_API_KEY is not set, replace the following line with: api_key="sk-xxx"
# API keys are region-specific. Get your API key: https://www.alibabacloud.com/help/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
def sample_sync_call_r2v():
# Synchronous call: blocks until the result is ready; 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.6-r2v-flash',
prompt='Character2 sits in a chair by the window, holding character3, playing a soothing American country folk song next to character4. Character1 says to Character2: “that sounds great”',
# reference_urls is an input-section field, not in the named signature; pass it through extra_input.
# shot_type and audio are parameters-section fields and are passed through parameters.
extra_input={'reference_urls': [
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/aacgyk/wan-r2v-role1.mp4",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/mmizqq/wan-r2v-role2.mp4",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qpzxps/wan-r2v-object4.png",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/wfjikw/wan-r2v-backgroud5.png"
]},
size='1280*720',
duration=10,
watermark=True,
parameters={'shot_type': 'multi', 'audio': 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_r2v()
Asynchronous
Asynchronous calls return the task ID immediately; use fetch to check the task status, or call wait to block until the task completes (with automatic polling).
Request example
import os
import dashscope
from dashscope.v2 import DashScopeError
# The following is the configuration for the Singapore (ap-southeast-1) region. Replace {WorkspaceId} with your Model Studio workspace ID. The region value varies by region.
client = dashscope.Client(
# If DASHSCOPE_API_KEY is not set, replace the following line with: api_key="sk-xxx"
# API keys are region-specific. Get your API key: https://www.alibabacloud.com/help/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
def sample_async_call_r2v_26():
# Asynchronous call: returns a task_id
try:
job = client.videos.jobs.create(
model='wan2.6-r2v-flash',
prompt='Character2 sits in a chair by the window, holding character3, playing a soothing American country folk song next to character4. Character1 says to Character2: “that sounds great”',
# reference_urls is an input-section field, not in the named signature; pass it through extra_input.
# shot_type and audio are parameters-section fields and are passed through parameters.
extra_input={'reference_urls': [
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/aacgyk/wan-r2v-role1.mp4",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/mmizqq/wan-r2v-role2.mp4",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qpzxps/wan-r2v-object4.png",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/wfjikw/wan-r2v-backgroud5.png"
]},
size='1280*720',
duration=10,
watermark=True,
parameters={'shot_type': 'multi', 'audio': True})
print(job)
print("task_id: %s" % job.task_id)
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")
return
# Fetch the task status
try:
snapshot = client.videos.jobs.fetch(job.task_id)
print(snapshot.status)
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")
# Wait for the task to complete (exponential backoff polling, default total budget of 24 hours)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.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_async_call_r2v_26()
Java
ImportantMake sure your DashScope Java SDK version is 2.22.14 or later before running the following code.
An outdated SDK version may cause errors such as "url error, please check url!". See Install the SDK to update.
Set baseHttpApiUrl based on the model's region:
Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID.
China (Beijing)
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID.
Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID.
Synchronous
Synchronous calls block until video generation completes and the result is returned.
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.List;
public class Ref2Video26 {
static {
// Singapore region URL. Use the URL for your region.
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// If DASHSCOPE_API_KEY is not set, replace the following line with: apiKey="sk-xxx"
// API keys are region-specific. Get your API key: https://www.alibabacloud.com/help/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void ref2video26() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
List<String> referenceUrls = new ArrayList<>();
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/aacgyk/wan-r2v-role1.mp4");
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/mmizqq/wan-r2v-role2.mp4");
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qpzxps/wan-r2v-object4.png");
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/wfjikw/wan-r2v-backgroud5.png");
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-r2v-flash")
.prompt("Character2 sits in a chair by the window, holding character3, playing a soothing American country folk song next to character4. Character1 says to Character2: “that sounds great”")
.referenceUrls(referenceUrls)
.shotType(VideoSynthesis.ShotType.MULTI)
.audio(Boolean.TRUE)
.size("1280*720")
.duration(10)
.watermark(Boolean.TRUE)
.build();
System.out.println("please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
ref2video26();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
Asynchronous
Asynchronous calls return a task ID immediately. You must poll or wait for the task to complete.
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisListResult;
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.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.ArrayList;
import java.util.List;
public class Ref2Video26Async {
static {
// Singapore region URL. Use the URL for your region.
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// If DASHSCOPE_API_KEY is not set, replace the following line with: apiKey="sk-xxx"
// API keys are region-specific. Get your API key: https://www.alibabacloud.com/help/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void asyncRef2video26() throws ApiException, NoApiKeyException, InputRequiredException, InterruptedException {
VideoSynthesis vs = new VideoSynthesis();
List<String> referenceUrls = new ArrayList<>();
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/aacgyk/wan-r2v-role1.mp4");
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20260205/mmizqq/wan-r2v-role2.mp4");
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qpzxps/wan-r2v-object4.png");
referenceUrls.add("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/wfjikw/wan-r2v-backgroud5.png");
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-r2v-flash")
.prompt("Character2 sits in a chair by the window, holding character3, playing a soothing American country folk song next to character4. Character1 says to Character2: “that sounds great”")
.referenceUrls(referenceUrls)
.shotType(VideoSynthesis.ShotType.MULTI)
.audio(Boolean.TRUE)
.size("1280*720")
.duration(10)
.watermark(Boolean.TRUE)
.build();
// Submit an asynchronous task
VideoSynthesisResult result = vs.asyncCall(param);
System.out.println("task_id: " + result.getOutput().getTaskId());
System.out.println(JsonUtils.toJson(result));
// Wait for the task to complete
result = vs.wait(result, null);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
asyncRef2video26();
} catch (ApiException | NoApiKeyException | InputRequiredException | InterruptedException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
Error codes
If the model call fails and returns an error message, see Error codes for resolution.