# 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-v2-6-pro-image-to-video",
"prompt": "A man making it to the summit on top of a mountain. The man raises his arms in victory and exhales a sigh of relief.",
"input_image": "https://hub.oxen.ai/api/repos/ox/Oxen-AI-Assets/file/main/images/man-hiking.png",
"negative_prompt": "blur, distort, and low quality",
"duration": 5,
"generate_audio": false
}' | 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 .