The Wan image-to-video model generates smooth videos from a first-frame image, a last-frame image, and an optional text prompt.
- Video specifications: Fixed 5-second duration and custom resolution (480P/720P/1080P).
- Additional capabilities: Prompt rewriting and watermarking.
Getting started
| Prompt | First frame | Last frame | Output video |
| A cute blue monster with a slightly sad expression stands in the rain. The camera slowly zooms in and stops on the moment it looks up at the sky. | ![]() | ![]() |
- Python SDK
- Java SDK
- curl
video_url expires after 24 hours. Download the video promptly.
Availability
- Supported models vary by region. Resources are isolated between regions. For supported models in each region, see the Model Studio console.
- When making a call, make sure your model, endpoint URL, and API key all belong to the same region. Cross-region calls fail.
Sample codes in this topic apply to the Singapore region.
Core capabilities
Generate video from first and last frames
Supported models: All models.
Generates smooth videos from first-frame and last-frame images.
Parameters:
first_frame_url: Required. Provide the first-frame image.last_frame_url: Required. Provide the last-frame image.prompt: Optional (recommended). Controls how the video changes over time.
| Prompt | First frame | Last frame | Output video |
| Realistic style. A curious black kitten looks up at the sky. The camera starts at eye level and gradually rises until it captures the kitten’s curious gaze from above. | ![]() | ![]() |
- Python SDK
- Java SDK
- curl
Requires DashScope Python SDK ≥ 1.25.8. Upgrade if needed.
Input image
- Number of images: One first-frame image and one last-frame image.
- Input methods: Image URL, local file path.
Method 1: Image URL (HTTP API and SDK) Recommended
Method 1: Image URL (HTTP API and SDK) Recommended
- Public URL: HTTP or HTTPS (e.g., https://xxxx/xxx.png).
Method 2: Local file path (SDK only)
Method 2: Local file path (SDK only)
Path requirements differ by language:Python SDK: Supports absolute and relative paths.
Java SDK: Supports absolute paths only.
Operating system | Input file path | Example (absolute path) | Example (relative path) |
|---|---|---|---|
Linux / macOS | file://{absolute or relative path} | file:///home/images/test.png | file://./images/test.png |
Windows | file://D:/images/test.png | file://./images/test.png |
Operating system | Input file path | Example (absolute path) |
|---|---|---|
Linux / macOS | file://{absolute path} | file:///home/images/test.png |
Windows | file:///{absolute path} | file:///D:/images/test.png |
Sample code: Multiple image input methods
Python SDK
Output video
- Number of videos: One.
- Specifications: Specifications vary by model. See Video specifications.
- URL expiration: 24 hours.
-
Dimensions: Determined by the first-frame image and the
resolutionsetting.- The model preserves the first-frame's aspect ratio and scales total pixel count to the target. Output dimensions are adjusted automatically to be divisible by 16 (encoding requirement).
- Example: 750×1000 input (3:4) with resolution="720P" (target ≈920K pixels) may output 816×1104 (≈0.739 ratio, ≈900K pixels, both divisible by 16).
Billing and rate limiting
- For free quota and pricing details, see Wanx-Image-to-Video-First-Last-Frame.
- For model rate limiting, see Wanxiang series.
-
Billing details:
- Input is free. Output billing is based on successful video seconds generated.
- Failed calls incur no charges and don't consume free quota.
- Image-to-video also supports savings plans.
API reference
Image-to-video - first and last frames - API reference
FAQ
Q: How do I generate a video with a specific aspect ratio (such as 3:4)?
A: The API doesn't support direct aspect ratio control -- only resolution.
The resolution parameter controls pixel count, not aspect ratio. The model preserves the first-frame's aspect ratio (first_frame_url) with minor adjustments for encoding (dimensions must be multiples of 16). For 3:4 video, upload a 3:4 first-frame image.
Example: 750×1000 input (3:4) with resolution="720P" (target ≈920K pixels) may output 816×1104 (≈0.739 ratio, ≈900K pixels, both divisible by 16).
Q: Why do I get a “url error, please check url!” error when running the SDK code?
A: Ensure your SDK version meets the minimum requirement: DashScope Python SDK ≥ 1.25.8 or DashScope Java SDK ≥ 2.22.6. Older versions may show "url error, please check url!" errors. Upgrade the SDK.


