Generate an AI video with curl and jq in one Bash script
One Bash script that submits a Sume video job with curl, polls until it finishes, and prints the file URL and the cost. A 6-second clip is 75 cents.

For a cron job or a CI step, curl and jq are enough. Sume's /v1/videos is asynchronous, so the script submits once and then polls the URL the first response gives back.
The code
Set SUME_API_KEY. The program submits one job, polls polling_url every 20 seconds until completed, and prints the first download URL.
#!/usr/bin/env bash
set -euo pipefail
AUTH="Authorization: Bearer ${SUME_API_KEY:?set SUME_API_KEY}"
POLL=$(curl -sf https://api.sume.com/v1/videos \
-H "$AUTH" -H 'Content-Type: application/json' \
-d '{"model":"sume/auto","prompt":"Steam over a night market","aspect_ratio":"9:16","duration":6}' \
| jq -r .polling_url)
while true; do
JOB=$(curl -sf "$POLL" -H "$AUTH")
STATUS=$(jq -r .status <<<"$JOB")
echo "status: $STATUS" >&2
case "$STATUS" in
completed) jq -r '.unsigned_urls[0], .usage.cost' <<<"$JOB"; break ;;
failed|cancelled) echo "$JOB" >&2; exit 1 ;;
esac
sleep 20
doneWhat to know
A 6-second sume/auto clip at the default 720p costs 75 cents (list $0.10 per second x 1.25 x 6 s = $0.75). The script prints the download URL and then usage.cost, the billable amount, so a pipeline can append it to a ledger.
Download the file with curl -o clip.mp4 and the first printed URL. Add an Idempotency-Key header to the POST when your scheduler may retry the script, so a retry does not create a second job.
Sources
Related posts
More in Developers
- Two failure channels in the Sume SDK: submit error vs failed job
A generateVideoV1 error means no job exists; a failed job means one did and billing was settled. Handle both channels in TypeScript without double-submitting.
- generation_spend_cap_usd on a Format run: null is $500, 0 is a 400
On a Format run request, omit generation_spend_cap_usd for the Format cap, send a number up to 500, null for the $500 maximum. 0 or above 500 returns 400.
- Get transcript text from a captioned video: caption jobs return none
A Sume caption job returns the burned video, not the transcript. For text and word times run STT or video inspect with transcribe. Prices and a recipe.
- Go: cancel the rest of a batch after the first 402 on Sume
A Go fan-out that stops launching Wan 3.0 submits the moment one returns 402 insufficient_credits, using context.WithCancel and a 2-slot semaphore.
Written by Sume