Create video generation task
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>"
}Video
Common video generation
Create and query video generation tasks with a unified protocol supporting text-to-video, image-to-video, first/last frames, and reference media
POST
/
v1
/
video
/
generations
Create video generation task
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>"
}The generic video generation API works asynchronously: you submit a creation request to get a
A successful creation returns the task ID:
task_id, then poll the query endpoint until the task succeeds and returns the video URL.
Features
- Access multiple video models through one unified protocol by specifying the platform model identifier in
model - Supports text-to-video and image-to-video (first frame / last frame / reference image / reference video / reference audio)
- Supports negative prompts, resolution, aspect ratio, duration, watermark, and random seed
- Media inputs accept public URLs and base64 data URIs
- Supports
callback_urlresult callbacks (only effective for the seedance channel; when empty, the gateway injects the default callback)
Authentication
Include theAuthorization header in the format Bearer YOUR_API_KEY.
Supported video models
Available video models in the Model Square, please refer to Model List.Quick example
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": "A golden retriever runs along the beach at sunset, camera slowly tracking",
"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: 'A golden retriever runs along the beach at sunset, camera slowly tracking',
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": "A golden retriever runs along the beach at sunset, camera slowly tracking",
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"watermark": false
}'
{
"task_id": "cgt-20260730120000-a1b2c3",
"status": "queued"
}
Next steps
- See Query video task to retrieve generation results
- See the Seedance protocol for native Seedance parameters
- See the Wan protocol for native Alibaba Wan parameters
- See the model list for available video models
Body
application/json
Platform model identifier
Negative prompt
Whether to generate audio; not supported by some models
Result callback URL (only effective for the seedance channel; when empty, the gateway injects the default callback)
Text prompt
Reference media input list (first frame / last frame / reference image / reference video / reference audio; URL or base64 data URI)
Show child attributes
Show child attributes
Generation duration (seconds)
Resolution tier, e.g. 480p/720p/1080p/4k (subject to model support)
Aspect ratio, e.g. 16:9/9:16/1:1/adaptive
Whether to include a watermark
Random seed