Generate realistic, smooth-motion videos from a first-frame image and an optional text prompt using the HappyHorse model.
Usage notes
The model, endpoint URL, and API key must belong to the same region. Cross-region calls fail.
NoteThe sample code in this topic applies to the China (Beijing) 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.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
- Singapore: from
https://dashscope-intl.aliyuncs.com to https://{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 calls
Image-to-video tasks take 1–5 minutes, so the API uses asynchronous calls. The workflow consists of two core steps: "create a task → poll for the result", as follows:
Step 1: Create a task
China (Beijing)
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Singapore
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
US (Virginia)
POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Germany (Frankfurt)
POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Japan (Tokyo)
POST https://{WorkspaceId}.ap-northeast-1.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_id to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result.
Request parameters Content-Type string (Required) The content type of the request. Must be application/json. Authorization string (Required) Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. X-DashScope-Async string (Required) Asynchronous processing configuration parameter. HTTP requests support only asynchronous calls and must be set to enable. ImportantIf this request header is missing, the error "current user api does not support synchronous calls" is returned. Request body model string (required) The model name. Allowed values:
happyhorse-1.1-i2v
happyhorse-1.0-i2v
input object (required) Model input, including the text prompt. Properties prompt string (optional) Describes the video content to generate. Supports any language. Maximum: 5,000 non-Chinese characters or 2,500 Chinese characters. Longer input is truncated. media array (required) The input media list. It specifies the images used for video generation. parameters object (optional) Video output settings such as resolution and duration. Properties resolution string (optional) Specifies the resolution tier of the generated video, which controls the video's clarity (total pixels). Based on the selected tier, the model automatically scales the output to a similar total pixel count. The output video's aspect ratio approximately matches that of the input first frame. Allowed values:
480P
720P
1080P (Default)
duration integer (optional) The duration of the generated video, in seconds. The value must be an integer in the range [3, 15]. Default: 5. watermark boolean (optional) Whether to add a watermark to the generated video. The watermark appears in the bottom-right corner with the fixed text "Happy Horse".
true (Default): Add the watermark.
false: Do not add the watermark.
seed integer (Optional) The random number seed, in the range [0, 2147483647]. If not specified, the system automatically generates a random seed. To improve the reproducibility of the results, we recommend using a fixed seed value. Note that model generation is probabilistic: even with the same seed, identical results are not guaranteed every time. | Image-to-video# The following URLs are for the Beijing region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "happyhorse-1.1-i2v",
"input": {
"prompt": "A cat running on the grass",
"media": [
{
"type": "first_frame",
"url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
}
]
},
"parameters": {
"resolution": "720P",
"duration": 5
}
}'
|
Response parameters output object The task's output. Properties task_id string The task ID. Valid for queries for 24 hours. task_status string The status of the task. Enumeration values
- PENDING: The task is queued.
- RUNNING: The task is being processed.
- SUCCEEDED: The task succeeded.
- FAILED: The task failed.
- CANCELED: The task was canceled.
- UNKNOWN: The task does not exist or its status is unknown.
request_id string Unique request identifier for tracing and troubleshooting. code string Error code. Returned only for failed requests. See Error codes. message string Detailed error message. Returned only for failed requests. See Error codes. | Successful responseSave the task_id to query the task status and result. {
"output": {
"task_status": "PENDING",
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
},
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}
Error responseTask creation failed. See Error codes. {
"code": "InvalidApiKey",
"message": "No API-key provided.",
"request_id": "7438d53d-6eb8-4596-8835-xxxxxx"
}
|
Step 2: Poll for the result
China (Beijing)
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Singapore
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
US (Virginia)
GET https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Germany (Frankfurt)
GET https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Japan (Tokyo)
GET https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Note
- Polling recommendation: Video generation takes several minutes. We recommend using a polling mechanism with a reasonable query interval (such as 15 seconds) to retrieve the result.
- 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 as UNKNOWN.
- RPS limit: The default RPS for the query API is 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
- More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parameters Request headers Authorization string (Required) Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. Path parameters task_id string (Required) The ID of the task. | Query task resultReplace {task_id} with the task_id value returned by the previous API call. The task_id is valid for 24 hours. Replace {WorkspaceId} with your actual workspace ID. curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
|
Response parameters outputobject The task's output. Properties task_id string The task ID. Valid for queries for 24 hours. task_status string The status of the task. Enumeration values
- PENDING: The task is queued.
- RUNNING: The task is being processed.
- SUCCEEDED: The task succeeded.
- FAILED: The task failed.
- CANCELED: The task was canceled.
- UNKNOWN: The task does not exist or its status is unknown.
State transitions during polling:
- PENDING → RUNNING → SUCCEEDED or FAILED.
- The initial query status is usually PENDING or RUNNING.
- When the status changes to SUCCEEDED, the response contains the generated video URL.
- If the status is FAILED, check the error message and retry the task.
- If the status is CANCELED, the task has been canceled. To continue, submit the task again.
- If the status is UNKNOWN, the task does not exist or its status is unknown. This can occur when the task_id does not exist or the 24-hour validity period has expired.
submit_time string The time when the task was submitted. Format: YYYY-MM-DD HH:mm:ss.SSS. scheduled_time string The time when the task was executed. Format: YYYY-MM-DD HH:mm:ss.SSS. end_time string The time when the task was completed. Format: YYYY-MM-DD HH:mm:ss.SSS. video_urlstring The video URL. Returned only when task_status is SUCCEEDED. The URL is valid for 24 hours. Download the MP4 video (24 fps, H.264 encoded) from this URL. orig_prompt string The original input prompt, corresponding to the request parameter prompt. code string Error code. Returned only for failed requests. See Error codes. message string Detailed error message. Returned only for failed requests. See Error codes. usage object Usage statistics. Calculated only for successful tasks. Properties input_video_duration integer The duration of the input video, in seconds. output_video_duration integer The duration of the output video, in seconds. duration integer The total video duration used for billing. SR integer The resolution tier of the output video. video_count integer The number of output videos. This value is always 1. request_id string Unique request identifier for tracing and troubleshooting. | Task successfulVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. {
"request_id": "8ae698ba-df2d-966c-abcf-xxxxxx",
"output": {
"task_id": "e56d806f-76f9-4037-aefa-xxxxxx",
"task_status": "SUCCEEDED",
"submit_time": "2026-04-20 19:33:50.425",
"scheduled_time": "2026-04-20 19:33:50.463",
"end_time": "2026-04-20 19:35:34.216",
"orig_prompt": "A cat running on the grass",
"video_url": "https://dashscope-result.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx"
},
"usage": {
"duration": 5,
"input_video_duration": 0,
"output_video_duration": 5,
"video_count": 1,
"SR": 720
}
}
Task failedWhen a task fails, task_status is FAILED with an error code and message. See Error codes. {
"request_id": "e5d70b02-ebd3-98ce-9fe8-759d7d7b107d",
"output": {
"task_id": "86ecf553-d340-4e21-af6e-a0c6a421c010",
"task_status": "FAILED",
"code": "InvalidParameter",
"message": "The parameter is invalid."
}
}
Task query expiredThe task_id is valid for 24 hours. After this period, queries return the following error. {
"request_id": "a4de7c32-7057-9f82-8581-xxxxxx",
"output": {
"task_id": "502a00b1-19d9-4839-a82f-xxxxxx",
"task_status": "UNKNOWN"
}
}
|
Error codes
If a call fails and returns an error, see Error codes for troubleshooting.
FAQ
Video aspect ratio
Output aspect ratio matches the first frame. Unlike the HappyHorse text-to-video model, image-to-video does not support the ratio parameter.