Skip to main content

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

Video generation can take minutes. The async queue returns immediately with a generation ID so you can avoid long-lived HTTP connections, run generations in parallel, and build progress-tracking UIs. You can either poll the queue or use SSE to receive events when generations complete.

Enqueue a Job

import requests

API_KEY = "YOUR_API_KEY"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

response = requests.post(
    "https://hub.oxen.ai/api/ai/queue",
    headers=HEADERS,
    json={
        "model": "kling-video-v2-6-pro-text-to-video",
        "prompt": "A sunset timelapse over the ocean",
        "duration": 5,
    },
)

generations = response.json()["generations"]
print(f"Enqueued {len(generations)} generation(s)")
for g in generations:
    print(g["generation_id"], g["status"])

Poll Until Done

Poll a generation by ID until its status reaches a terminal value (succeeded, failed, or cancelled). The response includes result_url on success and error_message on failure.
import time

generation_id = generations[0]["generation_id"]

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')}")
You can also list all active generations with GET /ai/queue to see how many are still in progress:
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://hub.oxen.ai/api/ai/queue?model=kling-video-v2-6-pro-text-to-video"

Fetch a Single Job

Use the generation ID to get a specific job’s full status, including result_url on success:
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://hub.oxen.ai/api/ai/queue/GENERATION_ID"

What’s Next