创建 Gemini 视频任务
curl --request POST \
--url https://api.aiohub.org/v1beta/models/{model}:predictLongRunning \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"instances": [
{
"prompt": "A blue ceramic cup on a wooden table in daylight."
}
],
"parameters": {
"durationSeconds": 4,
"aspectRatio": "16:9",
"resolution": "720p",
"generateAudio": true,
"sampleCount": 1
}
}
'import requests
url = "https://api.aiohub.org/v1beta/models/{model}:predictLongRunning"
payload = {
"instances": [{ "prompt": "A blue ceramic cup on a wooden table in daylight." }],
"parameters": {
"durationSeconds": 4,
"aspectRatio": "16:9",
"resolution": "720p",
"generateAudio": True,
"sampleCount": 1
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
instances: [{prompt: 'A blue ceramic cup on a wooden table in daylight.'}],
parameters: {
durationSeconds: 4,
aspectRatio: '16:9',
resolution: '720p',
generateAudio: true,
sampleCount: 1
}
})
};
fetch('https://api.aiohub.org/v1beta/models/{model}:predictLongRunning', 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}:predictLongRunning",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'instances' => [
[
'prompt' => 'A blue ceramic cup on a wooden table in daylight.'
]
],
'parameters' => [
'durationSeconds' => 4,
'aspectRatio' => '16:9',
'resolution' => '720p',
'generateAudio' => true,
'sampleCount' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aiohub.org/v1beta/models/{model}:predictLongRunning"
payload := strings.NewReader("{\n \"instances\": [\n {\n \"prompt\": \"A blue ceramic cup on a wooden table in daylight.\"\n }\n ],\n \"parameters\": {\n \"durationSeconds\": 4,\n \"aspectRatio\": \"16:9\",\n \"resolution\": \"720p\",\n \"generateAudio\": true,\n \"sampleCount\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aiohub.org/v1beta/models/{model}:predictLongRunning")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"instances\": [\n {\n \"prompt\": \"A blue ceramic cup on a wooden table in daylight.\"\n }\n ],\n \"parameters\": {\n \"durationSeconds\": 4,\n \"aspectRatio\": \"16:9\",\n \"resolution\": \"720p\",\n \"generateAudio\": true,\n \"sampleCount\": 1\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aiohub.org/v1beta/models/{model}:predictLongRunning")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"instances\": [\n {\n \"prompt\": \"A blue ceramic cup on a wooden table in daylight.\"\n }\n ],\n \"parameters\": {\n \"durationSeconds\": 4,\n \"aspectRatio\": \"16:9\",\n \"resolution\": \"720p\",\n \"generateAudio\": true,\n \"sampleCount\": 1\n }\n}"
response = http.request(request)
puts response.read_body{
"name": "models/doubao-seedance-2-5-260628/operations/task_example",
"done": false
}{
"code": "invalid_duration",
"message": "duration must be between 4 and 30 seconds for this model"
}创建视频 · Gemini API
使用 Gemini API 格式提交 Seedance 视频任务,查看示例、输入限制和完整参数。
POST
/
v1beta
/
models
/
{model}
:predictLongRunning
创建 Gemini 视频任务
curl --request POST \
--url https://api.aiohub.org/v1beta/models/{model}:predictLongRunning \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"instances": [
{
"prompt": "A blue ceramic cup on a wooden table in daylight."
}
],
"parameters": {
"durationSeconds": 4,
"aspectRatio": "16:9",
"resolution": "720p",
"generateAudio": true,
"sampleCount": 1
}
}
'import requests
url = "https://api.aiohub.org/v1beta/models/{model}:predictLongRunning"
payload = {
"instances": [{ "prompt": "A blue ceramic cup on a wooden table in daylight." }],
"parameters": {
"durationSeconds": 4,
"aspectRatio": "16:9",
"resolution": "720p",
"generateAudio": True,
"sampleCount": 1
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
instances: [{prompt: 'A blue ceramic cup on a wooden table in daylight.'}],
parameters: {
durationSeconds: 4,
aspectRatio: '16:9',
resolution: '720p',
generateAudio: true,
sampleCount: 1
}
})
};
fetch('https://api.aiohub.org/v1beta/models/{model}:predictLongRunning', 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}:predictLongRunning",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'instances' => [
[
'prompt' => 'A blue ceramic cup on a wooden table in daylight.'
]
],
'parameters' => [
'durationSeconds' => 4,
'aspectRatio' => '16:9',
'resolution' => '720p',
'generateAudio' => true,
'sampleCount' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aiohub.org/v1beta/models/{model}:predictLongRunning"
payload := strings.NewReader("{\n \"instances\": [\n {\n \"prompt\": \"A blue ceramic cup on a wooden table in daylight.\"\n }\n ],\n \"parameters\": {\n \"durationSeconds\": 4,\n \"aspectRatio\": \"16:9\",\n \"resolution\": \"720p\",\n \"generateAudio\": true,\n \"sampleCount\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aiohub.org/v1beta/models/{model}:predictLongRunning")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"instances\": [\n {\n \"prompt\": \"A blue ceramic cup on a wooden table in daylight.\"\n }\n ],\n \"parameters\": {\n \"durationSeconds\": 4,\n \"aspectRatio\": \"16:9\",\n \"resolution\": \"720p\",\n \"generateAudio\": true,\n \"sampleCount\": 1\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aiohub.org/v1beta/models/{model}:predictLongRunning")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"instances\": [\n {\n \"prompt\": \"A blue ceramic cup on a wooden table in daylight.\"\n }\n ],\n \"parameters\": {\n \"durationSeconds\": 4,\n \"aspectRatio\": \"16:9\",\n \"resolution\": \"720p\",\n \"generateAudio\": true,\n \"sampleCount\": 1\n }\n}"
response = http.request(request)
puts response.read_body{
"name": "models/doubao-seedance-2-5-260628/operations/task_example",
"done": false
}{
"code": "invalid_duration",
"message": "duration must be between 4 and 30 seconds for this model"
}使用 Gemini API 的长任务格式调用 Seedance。查询使用 GET,成功结果位于
返回的关键字段如下。保存完整
拿到任务标识后,转到 查询任务。
模型上限见 视频模型与计费。不支持任意
response.generateVideoResponse.generatedSamples。
如果客户端使用 Vertex AI 路径,请改看 Vertex AI 接口。
接入配置
服务地址为https://api.aiohub.org,使用 AIOHub API 令牌鉴权。把 <AIOHUB_API_KEY> 替换为完整的 sk- 令牌,并确认其分组可访问所选 Seedance 模型。
请求示例
curl "https://api.aiohub.org/v1beta/models/doubao-seedance-2-5-260628:predictLongRunning" \
-H "Authorization: Bearer <AIOHUB_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"instances": [{
"prompt": "A blue ceramic cup on a wooden table in daylight."
}],
"parameters": {
"durationSeconds": 4,
"aspectRatio": "16:9",
"resolution": "720p",
"generateAudio": true,
"sampleCount": 1
}
}'
name,包括模型路径和 operations/,不要只保存最后一段 ID。
{
"name": "models/doubao-seedance-2-5-260628/operations/task_example",
"done": false
}
输入与参数
未指定参数时,默认 5 秒、720p、adaptive 比例并生成音频。首尾帧与参考图是两种输入方式,不能在同一个 instances[0] 中混用。
图片对象示例:
{"bytesBase64Encoded": "<BASE64_IMAGE>", "mimeType": "image/png"}
gs:// 输入、视频扩展或全部 Veo 参数。需要参考音频、参考视频或视频编辑时,选择 Ark / Seedance。
SDK 完整示例
SDK 完整示例
安装
google-genai 并在运行环境中设置 AIOHUB_API_KEY。这里使用 Gemini API 模式,Base URL 不包含 /v1beta,版本通过 api_version 指定。Python
import os
import time
from google import genai
from google.genai import types
client = genai.Client(
api_key=os.environ["AIOHUB_API_KEY"],
http_options=types.HttpOptions(base_url="https://api.aiohub.org", api_version="v1beta"),
)
op = client.models.generate_videos(
model="doubao-seedance-2-0-260128-libtv",
source=types.GenerateVideosSource(prompt="木桌上的蓝色陶瓷杯,自然光。"),
config=types.GenerateVideosConfig(
number_of_videos=1, duration_seconds=4, aspect_ratio="16:9", resolution="720p"
),
)
while not op.done:
time.sleep(15)
op = client.operations.get(op)
if op.error:
raise RuntimeError(str(op.error))
video = op.response.generated_videos[0].video
with open("video.mp4", "wb") as f:
f.write(client.files.download(file=video))
授权
API key (sk-xxx)
路径参数
完整 Seedance 模型名。
示例:
"doubao-seedance-2-5-260628"
请求体
application/json