The HappyHorse image-to-video model generates physically realistic videos with smooth motion from a single image and an optional text description.
Availability
The model, endpoint URL, and API key must belong to the same region. Cross-region calls fail.
Select a model: Check which region the model belongs to.
Select a URL: Use the endpoint URL for the corresponding region. HTTP URLs are supported.
Configure an API key: Get an API key for the region, and then Export API key as an environment variable.
The sample code in this topic applies to the Singapore region.
HTTP request
Image-to-video tasks typically take 1 to 5 minutes, so the API uses asynchronous calls. The workflow has two steps: "Create a task -> Poll for results", as described below:
Step 1: Create a task and get the task ID
Singapore
POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Beijing
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
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 Postman.
Request parameters | Image-to-video (first frame) |
Content-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 Important If this request header is missing, the error "current user api does not support synchronous calls" is returned. | |
Request body | |
model The model to use for video generation. Valid values:
| |
input Input for the model. | |
parameters Video parameters such as resolution and duration. |
Response parameters | Successful responseSave the Error responseTask creation failed. See Error messages. |
output Task output information. | |
request_id Unique request identifier for tracing and troubleshooting. | |
code Error code. Returned only for failed requests. See Error messages. | |
message Detailed error message. Returned only for failed requests. See Error messages. |
Step 2: Query the result by task ID
Singapore
GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
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 parameters | Query task resultReplace |
Headers | |
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
Path parameters | |
task_id The ID of the task. |
Response parameters | Task succeededVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. Task failedWhen a task fails, Task query expiredThe |
output Task output information. | |
usage Output statistics. Only successful results are counted. | |
request_id Unique request identifier for tracing and troubleshooting. |
Error codes
If the API call fails, see Error messages for troubleshooting.
FAQ
How is the aspect ratio determined?
The aspect ratio of the image-to-video output automatically follows the input first frame image. Unlike HappyHorse - text-to-video, image-to-video does not support the ratio parameter.