查询 Gemini 视频任务
curl --request GET \
--url https://api.aiohub.org/v1beta/models/{model}/operations/{operation} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.aiohub.org/v1beta/models/{model}/operations/{operation}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.aiohub.org/v1beta/models/{model}/operations/{operation}', 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.aiohub.org/v1beta/models/{model}/operations/{operation}",
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: Bearer <token>"
],
]);
$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.aiohub.org/v1beta/models/{model}/operations/{operation}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.aiohub.org/v1beta/models/{model}/operations/{operation}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aiohub.org/v1beta/models/{model}/operations/{operation}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"name": "models/doubao-seedance-2-5-260628/operations/task_example",
"done": false
}
查询视频 · Gemini API
查询任务状态、判断成功或失败,并获取视频下载地址。
GET
/
v1beta
/
models
/
{model}
/
operations
/
{operation}
查询 Gemini 视频任务
curl --request GET \
--url https://api.aiohub.org/v1beta/models/{model}/operations/{operation} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.aiohub.org/v1beta/models/{model}/operations/{operation}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.aiohub.org/v1beta/models/{model}/operations/{operation}', 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.aiohub.org/v1beta/models/{model}/operations/{operation}",
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: Bearer <token>"
],
]);
$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.aiohub.org/v1beta/models/{model}/operations/{operation}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.aiohub.org/v1beta/models/{model}/operations/{operation}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aiohub.org/v1beta/models/{model}/operations/{operation}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"name": "models/doubao-seedance-2-5-260628/operations/task_example",
"done": false
}
查询与状态判断
把<OPERATION_NAME> 替换为创建响应的完整 name,每 10 到 15 秒查询一次:
curl "https://api.aiohub.org/v1beta/<OPERATION_NAME>" \
-H "Authorization: Bearer <AIOHUB_API_KEY>"
| 响应 | 处理 |
|---|---|
done: false | 继续查询 |
done: true 且包含 response | 下载视频 |
done: true 且包含 error | 停止查询,读取 error.message |
done: true 只表示任务结束,不代表成功。
读取成功结果
成功响应的关键字段:{
"name": "models/doubao-seedance-2-5-260628/operations/task_example",
"done": true,
"response": {
"generateVideoResponse": {
"generatedSamples": [
{
"video": {
"uri": "https://api.aiohub.org/v1beta/files/<FILE_NAME>:download?alt=media"
}
}
]
}
}
}
失败与重试
查询断线后用原name 继续查询,不要重新调用 predictLongRunning。收到 400 时先修正字段;任务结束后若有 error,不要读取成功结果字段。视频文件保留 72 小时,任务记录保留 7 天。
收到 429 或临时不可用错误时,等待后重试查询,不要重新创建任务。查询不到任务时,确认任务标识和 API 令牌所属账号。授权
API key (sk-xxx)
路径参数
完整 Seedance 模型名。
示例:
"doubao-seedance-2-5-260628"
创建响应 name 中 operations/ 后的任务标识,不是完整 name。
示例:
"task_example"