Documentation Index
Fetch the complete documentation index at: https://docs.oxen.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Generate videos from text descriptions, reference images, or existing videos.
Minimal Example (Synchronous)
Note: Synchronous generation can take 5-15 minutes to complete for certain models, we recommend using the async queue and polling for long-running jobs (See Below).
import requests
response = requests.post(
"https://hub.oxen.ai/api/ai/videos/generate",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "kling-video-v2-6-pro-text-to-video",
"prompt": "A red balloon floating upward through blue sky",
"duration": 5,
},
)
data = response.json()
print("Video URL:", data["videos"][0]["url"])
Async Generation (Recommended)
For video generation, using the async queue avoids long-lived HTTP connections:
import requests
import time
API_KEY = "YOUR_API_KEY"
MODEL = "kling-video-v2-6-pro-text-to-video"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
# 1. Enqueue
response = requests.post(
"https://hub.oxen.ai/api/ai/queue",
headers=HEADERS,
json={
"model": MODEL,
"prompt": "A sunset timelapse over the ocean",
"duration": 5,
},
)
generation_id = response.json()["generations"][0]["generation_id"]
print(f"Enqueued generation: {generation_id}")
# 2. Poll until done
while True:
data = requests.get(
f"https://hub.oxen.ai/api/ai/queue/{generation_id}",
headers=HEADERS,
).json()
print(f"Status: {data['status']}")
if data["status"] in {"succeeded", "failed", "cancelled"}:
break
time.sleep(10)
if data["status"] == "succeeded":
print(f"Done! Result: {data['result_url']}")
else:
print(f"Generation {data['status']}: {data.get('error_message')}")
What’s Next