Skip to main content

Overview

Generate videos from text descriptions, reference images, or existing videos. Video generation takes 1-5 minutes depending on the model and duration.

Minimal Example

import requests

response = requests.post(
    "https://hub.oxen.ai/api/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"])
For video generation, using the async queue avoids long-lived HTTP connections:
import requests
import time

API_KEY = "YOUR_API_KEY"
NAMESPACE = "YOUR_USERNAME"
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,
    },
)
generations = response.json()["generations"]
print(f"Enqueued {len(generations)} generation(s)")

# 2. Poll until done
while True:
    status = requests.get(
        f"https://hub.oxen.ai/api/media/generations/status/{NAMESPACE}/{MODEL}",
        headers=HEADERS,
    ).json()
    if status["count"] == 0:
        break
    print(f"Still processing: {status['count']} remaining")
    time.sleep(10)

print("Done!")

What’s Next