import httpx, orjson
url = "https://api.electronhub.ai/v1/videos/generations"
payload = {
"model": "midjourney-video",
"prompt": "a playful cat",
# "size": "16:9", # optional
}
headers = {
"Accept": "text/event-stream",
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
}
with httpx.stream("POST", url, json=payload, headers=headers, timeout=900) as response:
for line in response.iter_lines():
if line:
data = orjson.loads(line)
if data:
if data.get("heartbeat"):
print("Pending...")
else:
print(line)