The Wan first-and-last-frame-to-video model generates a smooth transition video based on a first frame image, a last frame image, and a text prompt. The supported features include the following:
Video specifications: The video duration is fixed at 5 seconds, and the video resolution is fixed at 720P.
Intelligent prompt optimization: This feature automatically rewrites input prompts, which significantly improves the results for short prompts.
Other: You can choose whether to add an "AI Generated" watermark.
Quick links: Try it online on the Wan official website
The features on the Wan official website may differ from the capabilities supported by the API. This document describes the actual capabilities of the API and will be updated as new features are released.
Model overview
Feature | Input example | Output video | ||
First frame image | Last frame image | Prompt | ||
Video generation from first and last frames |
|
| Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes. | |
Model name | Model description | Output video format |
wan2.1-kf2v-plus | Wan 2.1 Professional Edition (silent video) Complex motion, realistic physics, and detailed images. | Resolution options: 720P Video duration: 5 seconds Fixed specifications: 30 fps, MP4 (H.264 encoding) |
Before you make a call, check the model list and pricing for each region.
Prerequisites
Before making a call, obtain an API key and set the API key as an environment variable. If you use an SDK to make calls, install the DashScope SDK for Python or Java.
The Beijing and Singapore regions have separate API keys and request endpoints. Do not use them interchangeably. Cross-region calls cause authentication failures or service errors.
HTTP
Because image-to-video tasks take a long time to process (typically 1 to 5 minutes), the API uses asynchronous invocation. The entire process involves two core steps: Create a task -> Poll for the result.
The specific time required depends on the number of tasks in the queue and the service execution status. Please be patient while you wait for the result.
Step 1: Create a task to get a task ID
Singapore region: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Beijing region: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
After the task is created, use the returned
task_idto query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Use polling to retrieve the result.
Request parameters | Video generation from first and last framesGenerate a video based on the first frame, last frame, and prompt. Use a negative promptYou can use the negative_prompt parameter to prevent the "person" element from appearing in the generated video. |
Request headers | |
Content-Type The content type of the request. Set this parameter to | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
X-DashScope-Async The asynchronous processing configuration parameter. HTTP requests support only asynchronous processing. You must set this parameter to Important If this request header is missing, the error message "current user api does not support synchronous calls" is returned. | |
Request body | |
model The model name. Example: wan2.1-kf2v-plus. For more information, see Models and pricing. | |
input The basic input information, such as the prompt. | |
parameters Video processing parameters. |
Response parameters | Successful responseSave the task_id to query the task status and result. Error responseThe task creation failed. For more information, see Error messages to resolve the issue. |
output Task output information. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. |
Step 2: Query the result by task ID
Singapore region: GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing region: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Polling suggestion: Video generation takes several minutes. Use a polling mechanism and set a reasonable query interval, such as 15 seconds, to retrieve the result.
Task status transition: PENDING → RUNNING → SUCCEEDED or FAILED.
Result link: After the task is successful, a video link is returned. The link is valid for 24 hours. After you retrieve the link, immediately download and save the video to a permanent storage service, such as OSS.
task_id validity: 24 hours. After this period, you cannot query the result, and the API returns a task status of
UNKNOWN.
Request parameters | Query task resultReplace The API keys for the Singapore and Beijing regions are different. Create an API key. The following `base_url` is for the Singapore region. For models in the Beijing region, replace the `base_url` with `https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx`. |
Request headers | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
Path parameters | |
task_id The task ID. |
Response parameters | Task executed successfullyVideo URLs are retained for only 24 hours and are automatically purged after this period. You must save the generated videos promptly. Task execution failedIf a task fails, task_status is set to FAILED, and an error code and message are provided. For more information, see Error messages to resolve the issue. Task query expiredThe task_id is valid for 24 hours. After this period, the query fails and the following error message is returned. |
output Task output information. | |
usage The statistics on the output information. Only successful results are counted. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. |
DashScope SDK
The SDK's parameter names are mostly consistent with those of the HTTP API, and the parameter structure is encapsulated according to language-specific features.
Because image-to-video tasks take a long time to process (typically 1 to 5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer and supports both synchronous and asynchronous invocation methods.
The specific time required depends on the number of tasks in the queue and the service execution status. Please be patient while you wait for the result.
Python SDK
The Python SDK supports two image input methods: an Internet URL or a local file path (absolute or relative). For more information, see Input Images.
We recommend that you install the latest version of the DashScope Python SDK. Otherwise, you may encounter runtime errors: Install or upgrade the SDK.
Synchronous invocation
This example shows the synchronous invocation method, which includes two image input methods: a public URL and a local file path.
Request example
import os
from http import HTTPStatus
# dashscope sdk >= 1.23.4
from dashscope import VideoSynthesis
import dashscope
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# Get the DashScope API Key from environment variables (i.e., the Alibaba Cloud Model Studio API key)
api_key = os.getenv("DASHSCOPE_API_KEY")
# ========== Image input method (choose one) ==========
# [Method 1] Use a public image URL
first_frame_url = "https://wanx.alicdn.com/material/20250318/first_frame.png"
last_frame_url = "https://wanx.alicdn.com/material/20250318/last_frame.png"
# [Method 2] Use a local file path (file://+file path)
# Use an absolute path
# first_frame_url = "file://" + "/path/to/your/first_frame.png" # Linux/macOS
# last_frame_url = "file://" + "C:/path/to/your/last_frame.png" # Windows
# Or use a relative path
# first_frame_url = "file://" + "./first_frame.png" # Based on the actual path
# last_frame_url = "file://" + "./last_frame.png" # Based on the actual path
def sample_sync_call_kf2v():
print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model="wan2.1-kf2v-plus",
prompt="Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes.",
first_frame_url=first_frame_url,
last_frame_url=last_frame_url,
resolution="720P",
prompt_extend=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_sync_call_kf2v()Response example
The video_url is valid for 24 hours. You should download the video promptly.
{
"status_code": 200,
"request_id": "a37fafc3-907c-96f3-95a6-5b2a8268a3fd",
"code": null,
"message": "",
"output": {
"task_id": "4dba0092-da13-42b2-afb1-0f7b8a0f4643",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com/xxx.mp4?xxxxx",
"submit_time": "2025-05-23 15:50:12.404",
"scheduled_time": "2025-05-23 15:50:12.443",
"end_time": "2025-05-23 15:54:56.502",
"orig_prompt": "Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes.",
"actual_prompt": "Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes. its yellow eyes are bright and expressive, its ears are pricked, and its whiskers are clearly visible. The background is a simple light-colored wall, highlighting its black fur and focused expression. Close-up shot, emphasizing the change in its gaze and posture."
},
"usage": {
"video_count": 1,
"video_duration": 5,
"video_ratio": "standard"
}
}Asynchronous invocation
This example shows the asynchronous invocation method. This method immediately returns a task ID, and you need to poll for or wait for the task to complete on your own.
Request example
import os
from http import HTTPStatus
# dashscope sdk >= 1.23.4
from dashscope import VideoSynthesis
import dashscope
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# Get the DashScope API Key from environment variables (i.e., the Alibaba Cloud Model Studio API key)
api_key = os.getenv("DASHSCOPE_API_KEY")
# ========== Image input method (choose one) ==========
# [Method 1] Use a public image URL
first_frame_url = "https://wanx.alicdn.com/material/20250318/first_frame.png"
last_frame_url = "https://wanx.alicdn.com/material/20250318/last_frame.png"
# [Method 2] Use a local file path (file://+file path)
# Use an absolute path
# first_frame_url = "file://" + "/path/to/your/first_frame.png" # Linux/macOS
# last_frame_url = "file://" + "C:/path/to/your/last_frame.png" # Windows
# Or use a relative path
# first_frame_url = "file://" + "./first_frame.png" # Based on the actual path
# last_frame_url = "file://" + "./last_frame.png" # Based on the actual path
def sample_async_call_kf2v():
print('please wait...')
rsp = VideoSynthesis.async_call(api_key=api_key,
model="wan2.1-kf2v-plus",
prompt="Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes.",
first_frame_url=first_frame_url,
last_frame_url=last_frame_url,
resolution="720P",
prompt_extend=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("task_id: %s" % rsp.output.task_id)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# get the task information include the task status.
status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status) # check the task status
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# wait the task complete, will call fetch interval, and check it's in finished status.
rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_async_call_kf2v()Response example
1. Response example for creating a task
{
"status_code": 200,
"request_id": "c86ff7ba-8377-917a-90ed-xxxxxx",
"code": "",
"message": "",
"output": {
"task_id": "721164c6-8619-4a35-a6d9-xxxxxx",
"task_status": "PENDING",
"video_url": ""
},
"usage": null
}2. Response example for querying a task result
The video_url is valid for 24 hours. You should download the video promptly.
{
"status_code": 200,
"request_id": "efa545b3-f95c-9e3a-a3b6-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "721164c6-8619-4a35-a6d9-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?xxxxx",
"submit_time": "2025-02-12 11:03:30.701",
"scheduled_time": "2025-02-12 11:06:05.378",
"end_time": "2025-02-12 11:12:18.853",
"orig_prompt": "Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes.",
"actual_prompt": "Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes. its fur is jet black and shiny, its eyes are large and bright with golden pupils. It looks up with its ears pricked, appearing exceptionally focused. After the camera moves up, the kitten turns to look directly at the camera, its eyes full of curiosity and alertness. The background is simple, highlighting its detailed features. Close-up shot with soft, natural light."
},
"usage": {
"video_count": 1,
"video_duration": 5,
"video_ratio": "standard"
}
}Java SDK
The Java SDK supports two image input methods: an Internet URL or a local file path (absolute path). For more information, see Input images.
We recommend that you install the latest version of the DashScope Java SDK. Otherwise, a runtime error may occur: Install or upgrade the SDK.
Synchronous invocation
This example shows the synchronous invocation method, which includes two image input methods: a public URL and a local file path.
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
// dashscope sdk >= 2.20.1
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Kf2vSyncIntl {
static {
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// Get the DashScope API Key from environment variables (i.e., the Alibaba Cloud Model Studio API key)
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Image input method (choose one):
*
* [Method 1] Public URL
*/
static String firstFrameUrl = "https://wanx.alicdn.com/material/20250318/first_frame.png";
static String lastFrameUrl = "https://wanx.alicdn.com/material/20250318/last_frame.png";
/**
* [Method 2] Local file path (file://+absolute path or file:///+absolute path)
*/
// static String firstFrameUrl = "file://" + "/your/path/to/first_frame.png"; // Linux/macOS
// static String lastFrameUrl = "file:///" + "C:/path/to/your/img.png"; // Windows
public static void syncCall() {
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("resolution", "720P");
VideoSynthesis videoSynthesis = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.1-kf2v-plus")
.prompt("Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes.")
.firstFrameUrl(firstFrameUrl)
.lastFrameUrl(lastFrameUrl)
.parameters(parameters)
.build();
VideoSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = videoSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
} catch (InputRequiredException e) {
throw new RuntimeException(e);
}
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
syncCall();
}
}Response example
The video_url is valid for 24 hours. You should download the video promptly.
{
"request_id": "e6bb4517-c073-9c10-b748-dedb8c11bb41",
"output": {
"task_id": "984784fe-83c1-4fc4-88c7-52c2c1fa92a2",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com/xxx.mp4?xxxxx"
},
"usage": {
"video_count": 1,
"video_duration": 5,
"video_ratio": "standard"
}
}Asynchronous invocation
This example shows the asynchronous invocation method. This method immediately returns a task ID, and you need to poll for or wait for the task to complete on your own.
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
// dashscope sdk >= 2.20.1
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Kf2vAsync {
static {
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// Get the DashScope API Key from environment variables (i.e., the Alibaba Cloud Model Studio API key)
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Image input method (choose one)
*
* [Method 1] Public URL
*/
static String firstFrameUrl = "https://wanx.alicdn.com/material/20250318/first_frame.png";
static String lastFrameUrl = "https://wanx.alicdn.com/material/20250318/last_frame.png";
/**
* [Method 2] Local file path (file://+absolute path or file:///+absolute path)
*/
// static String firstFrameUrl = "file://" + "/your/path/to/first_frame.png"; // Linux/macOS
// static String lastFrameUrl = "file:///" + "C:/path/to/your/img.png"; // Windows
public static void asyncCall(){
// Set parameters
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("resolution", "720P");
VideoSynthesis videoSynthesis = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.1-kf2v-plus")
.prompt("Realistic style, a black kitten looks up at the sky curiously. The camera starts at eye level, gradually rises, and ends with a top-down shot of its curious eyes.")
.firstFrameUrl(firstFrameUrl)
.lastFrameUrl(lastFrameUrl)
.parameters(parameters)
.build();
VideoSynthesisResult result = null;
try {
System.out.println("---async call, please wait a moment----");
result = videoSynthesis.asyncCall(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
} catch (InputRequiredException e) {
throw new RuntimeException(e);
}
System.out.println(JsonUtils.toJson(result));
String taskId = result.getOutput().getTaskId();
System.out.println("taskId=" + taskId);
try {
result = videoSynthesis.wait(taskId, apiKey);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
System.out.println(JsonUtils.toJson(result.getOutput()));
}
public static void main(String[] args){
asyncCall();
}
}Response example
1. Response example for creating a task
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}2. Response example for querying a task result
The video_url is valid for 24 hours. You should download the video promptly.
{
"request_id": "1625235c-c13e-93ec-aff7-xxxxxxxx",
"output": {
"task_id": "464a5e46-79a6-46fd-9823-xxxxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?xxxxxx"
},
"usage": {
"video_count": 1,
"video_duration": 5,
"video_ratio": "standard"
}
}Limitations
Data validity: The task_id and video URL are retained for only 24 hours. After this period, they cannot be queried or downloaded.
Audio support: This feature supports generating silent videos only. Audio output is not supported. To add audio, you can generate it using speech synthesis.
Content moderation: The input prompt, input image, and output video are subject to content moderation. If the content is non-compliant, an "IPInfringementSuspect" or "DataInspectionFailed" error is returned. For more information, see Error messages.
Key parameter descriptions
Input image
The input image parameters first_frame_url and last_frame_url both support the following input methods:
Method 1: Public URL
A publicly accessible URL that supports the HTTP or HTTPS protocol.
Example:
https://example.com/images/cat.png.
Method 2: Local file path (SDK only)
Python SDK: Supports passing the absolute and relative paths of the file. The file path rules are as follows:
System
Passed file path
Example (absolute path)
Example (relative path)
Linux or macOS
file://{absolute or relative path of the file}
file:///home/images/test.png
file://./images/test.png
Windows
file://D:/images/test.png
file://./images/test.png
Java SDK: Only supports passing the absolute path of the file. The file path rules are as follows:
System
Passed file path
Example (absolute path)
Linux or macOS
file://{absolute path of the file}
file:///home/images/test.png
Windows
file:///{absolute path of the file}
file:///D:/images/test.png
Billing and rate limiting
For free quotas and pricing, see Models.
For rate limits, see Wan series.
Billing description:
Billing is based on the number of seconds of a successfully generated video. You are charged only when the query result API returns a
task_statusofSUCCEEDEDand a video is successfully generated.Failed model calls or processing errors do not incur fees or consume the free quota.
Error codes
If a model call fails and returns an error message, see Error messages to resolve the issue.
FAQ
Video FAQ quick link: FAQ.
Q: How do I generate a video with a specific aspect ratio (such as 3:4)?
A: The aspect ratio of the output video is determined by the input first frame image (img_url), but an exact ratio, such as a strict 3:4, cannot be guaranteed.
How it works: The model uses the aspect ratio of the input image as a baseline and then adapts it to a supported resolution based on the resolution parameter, such as 480p, 720p, or 1080p. Because the output resolution must meet technical requirements where the width and height must be divisible by 16, the final aspect ratio may have a slight deviation, for example, an adjustment from 0.75 to 0.739. This is normal behavior.
Example: An input image is 750 × 1000 (aspect ratio 3:4 = 0.75), and `resolution` is set to "720p" (target total pixels approx. 920,000). The actual output is 816 × 1104 (aspect ratio ≈ 0.739, total pixels approx. 900,000).
Note that the resolution parameter mainly controls the video's definition (total pixel count). The final video aspect ratio is still based on the input image, with only necessary minor adjustments.
Best practice: To strictly match a target aspect ratio, use an input image with that ratio and then post-process the output video by cropping or padding it. For example, you can use a video editing tool to crop the output video to the target ratio, or add black bars or a blurred background for padding.

