Complete a video generation

Create an asynchronous task, poll it reliably, and retrieve the video result.
Choose a video model in the marketplace

Text-to-video workflow

Creation returns a task object. Poll by task ID with capped backoff and a total timeout.

curl
#!/usr/bin/env bash
set -euo pipefail

task=$(curl -fsS https://api.noxgate.net/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL_ID","prompt":"Ocean waves at sunrise","duration":5,"ratio":"16:9"}')
task_id=$(printf '%s' "$task" | jq -r '.id')

for delay in 2 3 5 8 10 10 10 10 10 10; do
  sleep "$delay"
  task=$(curl -fsS "https://api.noxgate.net/v1/videos/generations/$task_id" \
    -H "Authorization: Bearer sk-your-api-key")
  status=$(printf '%s' "$task" | jq -r '.status')
  case "$status" in succeeded) printf '%s
' "$task" | jq .; exit 0 ;; failed|canceled|cancelled) printf '%s
' "$task" >&2; exit 1 ;; esac
done
echo "Video generation timed out" >&2
exit 1

Image-to-video workflow

When supported, add image_url, image_urls, or media. References must be reachable by the provider; ratio, duration, resolution, and generated audio are model-dependent.

curl
#!/usr/bin/env bash
set -euo pipefail

task=$(curl -fsS https://api.noxgate.net/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL_ID","image_url":"https://example.com/start.png","prompt":"A gentle camera move across the scene","duration":5}')
task_id=$(printf '%s' "$task" | jq -r '.id')
status=$(printf '%s' "$task" | jq -r '.status')
deadline=$((SECONDS + 600))
delay=2

while [[ "$status" != "succeeded" ]]; do
  case "$status" in failed|canceled|cancelled) printf '%s\n' "$task" >&2; exit 1 ;; esac
  [[ $SECONDS -ge $deadline ]] && { echo "Video generation timed out" >&2; exit 1; }
  sleep "$delay"
  task=$(curl -fsS "https://api.noxgate.net/v1/videos/generations/$task_id" \
    -H "Authorization: Bearer sk-your-api-key")
  status=$(printf '%s' "$task" | jq -r '.status')
  (( delay < 10 )) && delay=$((delay + 2))
done
printf '%s\n' "$task" | jq .

Terminal states, cancellation, and download

  • succeeded: read result.url and download it promptly.
  • failed: record error and the response request ID, then stop polling.
  • canceled or cancelled: treat the task as user-canceled.
  • Call DELETE /v1/videos/generations/:task_id when the task is no longer needed.
curl
curl -fsS -X DELETE "https://api.noxgate.net/v1/videos/generations/video_task_example" \
  -H "Authorization: Bearer sk-your-api-key"
echo "Cancellation accepted"
curl
#!/usr/bin/env bash
set -euo pipefail

task=$(curl -fsS "https://api.noxgate.net/v1/videos/generations/video_task_example" \
  -H "Authorization: Bearer sk-your-api-key")
status=$(printf '%s' "$task" | jq -r '.status')
[[ "$status" == "succeeded" ]] || { printf '%s\n' "$task" >&2; exit 1; }
result_url=$(printf '%s' "$task" | jq -r '.result.url // empty')
[[ -n "$result_url" ]] || { echo "Successful task has no result URL" >&2; exit 1; }
if [[ "$result_url" == /* ]]; then result_url="https://api.noxgate.net$result_url"; fi
curl -fL "$result_url" -o generated-video.mp4