# Enqueue, capture the generation id.
GEN_ID=$(curl -s -X POST https://hub.oxen.ai/api/ai/queue \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OXEN_API_KEY" \
-d '{
"model": "kling-video-o1-reference-to-video",
"prompt": "@Element1 flies into the scene and lands on the table next to the ox in @Image1",
"input_image": [
"https://hub.oxen.ai/api/repos/ox/Oxen-AI-Assets/file/main/images/daily_moo.png"
],
"elements": [
{
"frontal_image_url": "https://hub.oxen.ai/api/repos/ox/Oxen-AI-Assets/file/main/images/red_bird.png",
"reference_image_urls": [
"https://hub.oxen.ai/api/repos/ox/Oxen-AI-Assets/file/main/images/red_bird_side.png"
]
}
],
"aspect_ratio": "16:9",
"duration": 5
}' | jq -r '.generations[0].generation_id')
# Stream the SSE channel, grab the data line that follows a
# media_generation_completed event for our id, and pretty-print it.
curl -sN -H "Authorization: Bearer $OXEN_API_KEY" https://hub.oxen.ai/api/events \
| awk -v id="$GEN_ID" '
/^event: media_generation_completed$/ { expect=1; next }
/^data: / && expect {
payload = substr($0, 7)
if (index(payload, "\"generation_id\":\"" id "\"")) { print payload; exit }
expect = 0
}
' | jq .