创建视频生成任务
curl --request POST \
--url https://api.example.com/v1/video/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"negative_prompt": "<string>",
"generate_audio": true,
"callback_url": "<string>",
"prompt": "<string>",
"medias": [
{
"type": "<string>",
"url": "<string>",
"role": "<string>"
}
],
"duration": 123,
"resolution": "<string>",
"ratio": "<string>",
"watermark": true,
"seed": 123
}
'import requests
url = "https://api.example.com/v1/video/generations"
payload = {
"model": "<string>",
"negative_prompt": "<string>",
"generate_audio": True,
"callback_url": "<string>",
"prompt": "<string>",
"medias": [
{
"type": "<string>",
"url": "<string>",
"role": "<string>"
}
],
"duration": 123,
"resolution": "<string>",
"ratio": "<string>",
"watermark": True,
"seed": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
negative_prompt: '<string>',
generate_audio: true,
callback_url: '<string>',
prompt: '<string>',
medias: [{type: '<string>', url: '<string>', role: '<string>'}],
duration: 123,
resolution: '<string>',
ratio: '<string>',
watermark: true,
seed: 123
})
};
fetch('https://api.example.com/v1/video/generations', 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",
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([
'model' => '<string>',
'negative_prompt' => '<string>',
'generate_audio' => true,
'callback_url' => '<string>',
'prompt' => '<string>',
'medias' => [
[
'type' => '<string>',
'url' => '<string>',
'role' => '<string>'
]
],
'duration' => 123,
'resolution' => '<string>',
'ratio' => '<string>',
'watermark' => true,
'seed' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/v1/video/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"generate_audio\": true,\n \"callback_url\": \"<string>\",\n \"prompt\": \"<string>\",\n \"medias\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"ratio\": \"<string>\",\n \"watermark\": true,\n \"seed\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/v1/video/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"generate_audio\": true,\n \"callback_url\": \"<string>\",\n \"prompt\": \"<string>\",\n \"medias\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"ratio\": \"<string>\",\n \"watermark\": true,\n \"seed\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/video/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"generate_audio\": true,\n \"callback_url\": \"<string>\",\n \"prompt\": \"<string>\",\n \"medias\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"ratio\": \"<string>\",\n \"watermark\": true,\n \"seed\": 123\n}"
response = http.request(request)
puts response.read_body{
"task_id": "<string>",
"status": "<string>"
}视频
通用视频生成接口
创建并查询视频生成任务,统一协议支持文生视频、图生视频、首尾帧与参考媒体输入
POST
/
v1
/
video
/
generations
创建视频生成任务
curl --request POST \
--url https://api.example.com/v1/video/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"negative_prompt": "<string>",
"generate_audio": true,
"callback_url": "<string>",
"prompt": "<string>",
"medias": [
{
"type": "<string>",
"url": "<string>",
"role": "<string>"
}
],
"duration": 123,
"resolution": "<string>",
"ratio": "<string>",
"watermark": true,
"seed": 123
}
'import requests
url = "https://api.example.com/v1/video/generations"
payload = {
"model": "<string>",
"negative_prompt": "<string>",
"generate_audio": True,
"callback_url": "<string>",
"prompt": "<string>",
"medias": [
{
"type": "<string>",
"url": "<string>",
"role": "<string>"
}
],
"duration": 123,
"resolution": "<string>",
"ratio": "<string>",
"watermark": True,
"seed": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
negative_prompt: '<string>',
generate_audio: true,
callback_url: '<string>',
prompt: '<string>',
medias: [{type: '<string>', url: '<string>', role: '<string>'}],
duration: 123,
resolution: '<string>',
ratio: '<string>',
watermark: true,
seed: 123
})
};
fetch('https://api.example.com/v1/video/generations', 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",
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([
'model' => '<string>',
'negative_prompt' => '<string>',
'generate_audio' => true,
'callback_url' => '<string>',
'prompt' => '<string>',
'medias' => [
[
'type' => '<string>',
'url' => '<string>',
'role' => '<string>'
]
],
'duration' => 123,
'resolution' => '<string>',
'ratio' => '<string>',
'watermark' => true,
'seed' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/v1/video/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"generate_audio\": true,\n \"callback_url\": \"<string>\",\n \"prompt\": \"<string>\",\n \"medias\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"ratio\": \"<string>\",\n \"watermark\": true,\n \"seed\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/v1/video/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"generate_audio\": true,\n \"callback_url\": \"<string>\",\n \"prompt\": \"<string>\",\n \"medias\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"ratio\": \"<string>\",\n \"watermark\": true,\n \"seed\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/video/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"generate_audio\": true,\n \"callback_url\": \"<string>\",\n \"prompt\": \"<string>\",\n \"medias\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"ratio\": \"<string>\",\n \"watermark\": true,\n \"seed\": 123\n}"
response = http.request(request)
puts response.read_body{
"task_id": "<string>",
"status": "<string>"
}通用视频生成接口采用异步任务模式:你先调用创建接口获得
创建成功后返回任务 ID:
task_id,再通过查询接口轮询任务状态,任务成功后从响应中获取视频地址。
功能特性
- 统一协议接入多个视频模型,通过
model指定平台模型标识 - 支持文生视频、图生视频(首帧 / 尾帧 / 参考图 / 参考视频 / 参考音频)
- 支持负向提示词、分辨率、宽高比、时长、水印与随机种子等生成参数
- 媒体输入支持公网 URL 与 base64 data URI
- 支持
callback_url结果回调(仅 seedance 渠道生效;为空时由网关注入默认回调)
认证方式
在请求头中携带Authorization 字段,格式为 Bearer YOUR_API_KEY。
支持的视频模型
模型广场中可用的视频模型,请参考 模型列表。快速示例
import requests
url = "https://api.haitoken.ai/v1/video/generations"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "seedance-2.0",
"prompt": "一只金毛犬在日落的海边奔跑,镜头缓慢跟随",
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"watermark": False
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
const response = await fetch('https://api.haitoken.ai/v1/video/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'seedance-2.0',
prompt: '一只金毛犬在日落的海边奔跑,镜头缓慢跟随',
duration: 5,
resolution: '720p',
ratio: '16:9',
watermark: false
})
});
const data = await response.json();
console.log(data);
curl -X POST 'https://api.haitoken.ai/v1/video/generations' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "seedance-2.0",
"prompt": "一只金毛犬在日落的海边奔跑,镜头缓慢跟随",
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"watermark": false
}'
{
"task_id": "cgt-20260730120000-a1b2c3",
"status": "queued"
}
下一步
- 查看查询视频任务获取生成结果
- 查看 Seedance 协议 了解 Seedance 原生参数
- 查看 万相协议 了解阿里万相原生参数
- 查看 模型列表 了解可用的视频模型
请求体
application/json
平台模型标识
负向提示词
是否生成音频,部分模型不支持
结果回调地址(仅 seedance 渠道生效;空则由网关注入默认回调)
文本提示词
参考媒体输入列表(首帧/尾帧/参考图/参考视频/参考音频;URL 或 base64 data URI)
Show child attributes
Show child attributes
生成时长(秒)
分辨率档位,如 480p/720p/1080p/4k(视模型支持情况)
宽高比,如 16:9/9:16/1:1/adaptive
是否带水印
随机种子