Query task (HappyHorse compatible protocol)
curl --request GET \
--url https://api.example.com/v1/alibaba/video/generations/{taskId} \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/v1/alibaba/video/generations/{taskId}"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/v1/alibaba/video/generations/{taskId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/alibaba/video/generations/{taskId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/alibaba/video/generations/{taskId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/alibaba/video/generations/{taskId}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/alibaba/video/generations/{taskId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"output": {
"task_id": "<string>",
"task_status": "<string>",
"submit_time": "<string>",
"scheduled_time": "<string>",
"end_time": "<string>",
"video_url": "<string>",
"orig_prompt": "<string>",
"code": "<string>",
"message": "<string>"
},
"usage": {
"input_video_duration": 123,
"output_video_duration": 123,
"video_count": 123,
"SR": 123,
"ratio": "<string>",
"duration": 123
}
}Video
HappyHorse query video task
Query the status and result of a HappyHorse-compatible video task
GET
/
v1
/
alibaba
/
video
/
generations
/
{taskId}
Query task (HappyHorse compatible protocol)
curl --request GET \
--url https://api.example.com/v1/alibaba/video/generations/{taskId} \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/v1/alibaba/video/generations/{taskId}"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/v1/alibaba/video/generations/{taskId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/alibaba/video/generations/{taskId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/alibaba/video/generations/{taskId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/alibaba/video/generations/{taskId}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/alibaba/video/generations/{taskId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"output": {
"task_id": "<string>",
"task_status": "<string>",
"submit_time": "<string>",
"scheduled_time": "<string>",
"end_time": "<string>",
"video_url": "<string>",
"orig_prompt": "<string>",
"code": "<string>",
"message": "<string>"
},
"usage": {
"input_video_duration": 123,
"output_video_duration": 123,
"video_count": 123,
"SR": 123,
"ratio": "<string>",
"duration": 123
}
}Use the
output.task_id returned at creation to query the task. The response preserves the HappyHorse-compatible structure, with the video URL in output.video_url after success.
The task and
video_url are retained for only 24 hours. Download and store the video promptly after success.Polling example
Python
import time
import requests
task_id = "cgt-20260730120000-a1b2c3"
url = f"https://api.haitoken.ai/v1/alibaba/video/generations/{task_id}"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
while True:
result = requests.get(url, headers=headers).json()
output = result.get("output", {})
status = output.get("task_status")
if status == "SUCCEEDED":
print(output["video_url"])
break
if status in ("FAILED", "CANCELED", "UNKNOWN"):
print(output.get("code"), output.get("message"))
break
time.sleep(5)