curl --json: submit a Wan 3.0 video to Sume in one flag

curl 7.82 and later has --json, which sets the body and the JSON headers for you. A Wan 3.0 submit with an Idempotency-Key, then a status poll with jq.

3 min readSume
All posts

curl --json '<body>' is shorthand for sending the data with Content-Type: application/json and Accept: application/json, and it keeps the body byte-for-byte like --data-binary. It arrived in curl 7.82.0. On curl 8.7.1 it replaced a three-flag submit with one. The sample below posted to a local stand-in server that answers 202; the same call works against https://api.sume.com.

Sume wants exactly one credential header, so pass x-api-key and leave Authorization off.

Submit

A five-second Wan 3.0 clip at 480p costs $0.3125 on Sume (provider list $0.05 a second, x 1.25). The Idempotency-Key makes a retry of this exact call return the same job.

curl -s https://api.sume.com/v1/videos \
  -H "x-api-key: $SUME_API_KEY" \
  -H 'Idempotency-Key: kite-json-1' \
  --json '{"model":"wan-3.0","prompt":"a red kite","duration":5,"resolution":"480p"}'

What comes back

A 202 with id, polling_url, status (pending) and model. Capture the id and poll.

ID=$(curl -s https://api.sume.com/v1/videos --json @body.json -H "x-api-key: $SUME_API_KEY" \
  -H 'Idempotency-Key: kite-json-2' | jq -r .id)
curl -s "https://api.sume.com/v1/videos/$ID" -H "x-api-key: $SUME_API_KEY" | jq -r .status

Caveats

Older curl (before 7.82) rejects --json; fall back to -H 'content-type: application/json' --data-binary. A prompt with quotes or backslashes breaks hand-written JSON on the command line, so build the body with jq -n --arg and pass the file (see the related jq post). Statuses to poll for are pending, in_progress, completed, failed and cancelled.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume