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,
},
)
generations = response.json()["generations"]
print(f"Enqueued {len(generations)} generation(s)")
# 2. Poll until done
while True:
status = requests.get(
"https://hub.oxen.ai/api/ai/queue",
headers=HEADERS,
params={"model": MODEL},
).json()
if status["count"] == 0:
break
print(f"Still processing: {status['count']} remaining")
time.sleep(10)
print("Done!")