The HappyHorse video editing model takes a video and a reference image as input, and performs editing tasks such as style transfer and local replacement based on text instructions.
Availability
Make sure that the model, endpoint URL, and API key all belong to the same region. Cross-region calls will 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: Select a region and Create an API key, then Export API key as environment variable.
The sample code in this topic applies to the Singapore region.
HTTP request
Video editing tasks are time-consuming (typically 1–5 minutes), so the API uses asynchronous calls. The workflow has two steps: "Create a task -> Poll for result" as described below:
Step 1: Create a task and get the task ID
- Singapore
- US (Virginia)
- China (Beijing)
- Germany (Frankfurt)
- Japan (Tokyo)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- 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-Typestring (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)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.Request bodymodelstring (Required)The model name.Fixed value: happyhorse-1.0-video-edit.input object (Required)The input information, including the video to edit, reference images, and the prompt.
Properties prompt string (Required)The text prompt describing the intended edit, such as style transfer or local replacement.Supports any language. Maximum 5,000 non-Chinese characters or 2,500 Chinese characters. Content beyond this limit is automatically truncated.media array (Required)The list of media assets, including the video to edit and optional reference images.The array must contain exactly 1 video element and can optionally contain 0–5 reference_image elements.
Element properties type string (Required)The media asset type. Must be one of:
string (Required)The URL of the media asset.
Video input (type=video) A publicly accessible URL of the video to edit.
Output video duration: 3–15 seconds.
Image input (type=reference_image) URL or Base64-encoded data of the reference image.Image requirements:
object (Optional)Video editing parameters such as resolution.
Properties resolution string (Optional)Resolution of the generated video.Valid values:
boolean (Optional)Whether to add a watermark to the generated video. The watermark appears in the bottom-right corner with the text "Happy Horse". Defaults to true.
string (Optional)Audio control.
integer (Optional)The random number seed must be an integer in the range [0, 2147483647].If not specified, a random seed is generated. A fixed seed improves reproducibility.Because model generation is probabilistic, the same seed does not guarantee identical results. |
|
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query results by task ID
- Singapore
- US (Virginia)
- China (Beijing)
- Germany (Frankfurt)
- Japan (Tokyo)
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}- Polling: Video editing takes several minutes. Use a polling mechanism with a reasonable interval (for example, 15 seconds) to check for results.
- Task status flow: PENDING (queued) → RUNNING (processing) → SUCCEEDED / FAILED.
- task_id expiration: The task_id expires after 24 hours. After expiration, results can no longer be retrieved and the API returns a task status of
UNKNOWN.
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.video_url stringURL of the generated video. Returned only when task_status is SUCCEEDED.Valid for 24 hours. The video is in MP4 format with H.264 encoding.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectUsage statistics. Only counts successful results.
Properties duration floatTotal video duration of the generated video, used for billing.SR integerResolution tier of the generated video.output_video_duration floatDuration of the output video, in seconds.input_video_duration floatDuration of the input video, in seconds.video_count integerNumber of generated videos. Always 1.stringUnique request identifier for tracing and troubleshooting. |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |