查询视频生成任务状态
curl --request GET \
--url https://api.example.com/v1/video/generations/{taskId} \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/v1/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/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/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/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/video/generations/{taskId}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/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{
"task_id": "<string>",
"video_url": "<string>",
"video_duration": 123,
"error_code": "<string>",
"error_message": "<string>",
"status": "<string>",
"resolution": "<string>",
"ratio": "<string>",
"model": "<string>",
"created": 123,
"updated": 123,
"usage": {
"input_video_duration": 123,
"output_video_duration": 123,
"total_tokens": 123,
"duration": 123
}
}视频
通用视频任务查询
查询通用视频生成任务的状态与生成结果
GET
/
v1
/
video
/
generations
/
{taskId}
查询视频生成任务状态
curl --request GET \
--url https://api.example.com/v1/video/generations/{taskId} \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/v1/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/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/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/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/video/generations/{taskId}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/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{
"task_id": "<string>",
"video_url": "<string>",
"video_duration": 123,
"error_code": "<string>",
"error_message": "<string>",
"status": "<string>",
"resolution": "<string>",
"ratio": "<string>",
"model": "<string>",
"created": 123,
"updated": 123,
"usage": {
"input_video_duration": 123,
"output_video_duration": 123,
"total_tokens": 123,
"duration": 123
}
}使用创建视频任务时返回的
task_id 查询生成状态。任务成功后,响应中会包含视频地址。
建议每 10-15 秒轮询一次。视频生成通常需要几十秒到数分钟。
轮询示例
Python
import time
import requests
task_id = "cgt-20260730120000-a1b2c3"
url = f"https://api.haitoken.ai/v1/video/generations/{task_id}"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
while True:
result = requests.get(url, headers=headers).json()
if result["status"] == "succeeded":
print(result["video_url"])
break
if result["status"] in ("failed", "cancelled", "expired"):
break
time.sleep(5)
路径参数
响应
200 - application/json
通用视频任务状态查询响应
任务ID
视频地址(成功时;上游地址)
视频时长(秒,成功时)
错误码(失败时)
错误信息(失败时)
任务状态:queued / running / succeeded / failed / cancelled / expired
生成视频分辨率:480p / 720p / 1080p / 4k
生成视频宽高比:16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9
平台模型编号(model_no,用于协议透传时替换上游 model 名称)
创建时间(epoch 毫秒)-UTC标准时间
更新时间(epoch 毫秒)-UTC标准时间
用量统计(成功时;时长类取自万相 usage,token 类取自 seedance usage)
Show child attributes
Show child attributes