Skip to main content

Video Generation

Available Models

The full list of models can be viewed on the Models page or retrieved dynamically via the API endpoint: https://openai.bothub.chat/v1/videos/models

BotHub provides a dedicated API for video generation, compatible with asynchronous processing patterns. Video generation is a long-running operation — the request returns immediately with a pending status, and you poll for the result using the video ID.


How It Works​

  1. Send a generation request — POST /v1/videos/generations returns immediately with status: "pending" and a video id.
  2. Poll for status — Periodically call GET /v1/videos/:videoId until status becomes "completed" or "failed".
  3. Download the video — On completion, unsigned_urls contains the URL(s) of the generated video.

Endpoints​

POST /v1/videos/generations​

Creates a new video generation request. Returns immediately — generation happens asynchronously.

Base URL: https://openai.bothub.chat

Authentication: Authorization: Bearer YOUR_BOTHUB_API_KEY

Request Body​

FieldTypeDescription
modelstringModel ID (e.g., veo-3.1, kling-v2.6)
promptstringText description of the video to generate
imageUrlstringInput image URL for image-to-video generation (optional)
notifybooleanSend email notification on completion (optional)
settingsobjectGeneration settings (see below)

Settings Object​

FieldTypeDescription
duration_secondsnumberVideo duration: 4, 5, 6, 7, 8, 9, 10, or 12
aspect_ratiostringe.g. "16:9", "9:16", "1:1"
negative_promptstringThings to avoid in the generation
generate_audiobooleanWhether to generate audio
seednumberSeed for reproducible results
Model-specific parameters

Each model supports different settings. Refer to the model's documentation on the Models page for the full parameter list.


GET /v1/videos/{videoId}​

Returns the current status and result of a video generation request.

Query ParamDescription
include_usagePass "true" to include caps usage in the response

GET /v1/videos/models​

Returns the list of available video generation models.


Text-to-Video​

async function generateVideo() {
const BASE_URL = 'https://openai.bothub.chat/v1';
const API_KEY = 'YOUR_BOTHUB_API_KEY';

// Step 1: Create the generation request
const createRes = await fetch(`${BASE_URL}/videos/generations`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${API_KEY}`,
},
body: JSON.stringify({
model: 'veo-3.1',
prompt: 'A time-lapse of a blooming flower in a sunny garden',
notify: false,
settings: {
duration_seconds: 6,
aspect_ratio: '16:9',
},
}),
});

const { id } = await createRes.json();
console.log('Request created, id:', id);

// Step 2: Poll until completed
let video;
while (true) {
await new Promise((r) => setTimeout(r, 10000));
const statusRes = await fetch(`${BASE_URL}/videos/${id}?include_usage=true`, {
headers: { Authorization: `Bearer ${API_KEY}` },
});
video = await statusRes.json();
console.log('Status:', video.status);
if (video.status === 'completed' || video.status === 'failed') break;
}

if (video.status === 'completed') {
console.log('Video URL:', video.unsignedUrls[0]);
} else {
console.error('Generation failed:', video.error);
}
}

generateVideo();

Response — Step 1 (creation):​

{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"modelId": "veo-3.1",
"providerId": "replicate",
"status": "pending",
"createdAt": "2025-01-15T10:30:00Z",
"userId": "user-id",
"error": null,
"payment": false,
"notify": false,
"unsigned_urls": []
}

Response — Step 2 (completed):​

{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"modelId": "veo-3.1",
"providerId": "replicate",
"status": "completed",
"createdAt": "2025-01-15T10:30:00Z",
"userId": "user-id",
"error": null,
"payment": true,
"notify": false,
"unsigned_urls": [
"https://storage.bothub.chat/videos/a1b2c3d4-e5f6-7890-abcd-ef1234567890.mp4"
],
"outputFileId": "file-uuid",
"usage": {
"caps": 250
}
}

Image-to-Video​

Pass imageUrl to animate a still image. The model will use it as the first frame of the video.

async function imageToVideo() {
const BASE_URL = 'https://openai.bothub.chat/v1';
const API_KEY = 'YOUR_BOTHUB_API_KEY';

const createRes = await fetch(`${BASE_URL}/videos/generations`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${API_KEY}`,
},
body: JSON.stringify({
model: 'kling-v2.6',
prompt: 'The person slowly turns and smiles at the camera',
imageUrl: 'https://example.com/portrait.jpg',
notify: false,
settings: {
duration_seconds: 5,
aspect_ratio: '9:16',
negative_prompt: 'blurry, low quality',
},
}),
});

const { id } = await createRes.json();

// Poll for result
let video;
while (true) {
await new Promise((r) => setTimeout(r, 10000));
const res = await fetch(`${BASE_URL}/videos/${id}`, {
headers: { Authorization: `Bearer ${API_KEY}` },
});
video = await res.json();
if (video.status === 'completed' || video.status === 'failed') break;
}

console.log(video.status === 'completed' ? video.unsignedUrls[0] : video.error);
}

imageToVideo();

List Available Models​

const res = await fetch('https://openai.bothub.chat/v1/videos/models', {
headers: { Authorization: 'Bearer YOUR_BOTHUB_API_KEY' },
});
const { data } = await res.json();
console.log(data.map((m) => m.id));

Example Response:​

{
"object": "list",
"data": [
{ "id": "veo-3.1", "object": "model", "created": 1705334400, "owned_by": "replicate" },
{ "id": "kling-v2.6", "object": "model", "created": 1705334400, "owned_by": "replicate" },
{ "id": "gen4_turbo", "object": "model", "created": 1705334400, "owned_by": "runway" }
]
}

Status Reference​

StatusDescription
pendingGeneration is in progress
completedVideo is ready — see unsigned_urls
failedGeneration failed — see error for details

Tips​

  • Polling interval: Poll every 10–15 seconds. Most models complete within 1–3 minutes.
  • Email notifications: Set notify: true to receive an email when generation finishes — useful for long-running jobs.
  • Duration limits: Available values depend on the model. When in doubt, use 5 or 6 seconds.
  • Image-to-video: The imageUrl must be a publicly accessible URL. Supported formats: JPEG, PNG, WebP.