Python: submit, poll and download one Omni Flash clip (v1/videos)
A short Python script that submits a Gemini Omni Flash 1.1 request to Sume's /v1/videos, polls the job until it completes and saves the MP4.

The whole workflow is submit, poll, download: POST to /v1/videos returns a job id and polling_url at once, and the clip is fetched from unsigned_urls[0] after the status reaches completed. The script below does that with requests and nothing else.
Script
Set SUME_API_KEY first. The 30 second sleep is the interval the docs suggest.
import os, time, requests
H = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}
body = {
"model": "gemini-omni-flash-1.1",
"prompt": "A cat hops onto a sunlit windowsill, soft purr and street sounds",
"duration": 3,
"resolution": "360p",
"aspect_ratio": "9:16",
}
r = requests.post("https://api.sume.com/v1/videos", json=body,
headers={**H, "Idempotency-Key": "omni-py-001"}, timeout=60)
r.raise_for_status()
url = r.json()["polling_url"]
while True:
s = requests.get(url, headers=H, timeout=60).json()
if s["status"] == "completed":
break
if s["status"] in ("failed", "cancelled"):
raise SystemExit(s.get("error", s["status"]))
time.sleep(30)
video = requests.get(s["unsigned_urls"][0], headers=H, timeout=300)
open("omni.mp4", "wb").write(video.content)
print("saved omni.mp4, cost", s.get("usage", {}).get("cost"))What each step does
Idempotency-Keymakes a rerun return the original job instead of a second charge.failedcarries anerrorfield;cancelledis the spelling/v1/videosuses.usage.coston the poll response is the Sume billable amount.
What this costs
The example is 3 seconds at 360p, $0.1125. Change resolution and duration and the same loop handles a 10 second 4K job at $3.75; only the wait changes.
Choose the resolution and length
Omni Flash accepts 3 to 10 seconds, in 16:9 or 9:16, at 360p, 720p, 1080p or 4K. Billing is per output second, so the reserve is the per-second rate times the duration. Swap the two fields in the script and the rest of the loop stays the same.
| Resolution | Per second | 3 s clip | 10 s clip |
|---|---|---|---|
| 360p | $0.0375 | $0.1125 | $0.375 |
| 720p | $0.125 | $0.375 | $1.25 |
| 1080p | $0.1875 | $0.5625 | $1.875 |
| 4K | $0.375 | $1.125 | $3.75 |
When the submit fails
If the balance cannot cover the reserve, the POST returns 402 insufficient_credits and raise_for_status() raises before any polling starts. A 429 means the workspace has no accepted-job capacity right now; wait and resubmit with the same Idempotency-Key. The errors and generation admission pages in the Sume docs list the codes.
Sources
Related posts
More in Developers
- Railway closes idle HTTP at 5 minutes: why Sume sync waits 30 s
Railway keeps a request open up to 15 minutes only while data moves. Sume sync mode caps the wait at 30 seconds, so long video jobs need async or a webhook.
- Worker crashed mid-poll: list Sume jobs and join on idempotency_key
After a restart, GET /v1/jobs?status=processing lists your in-flight video jobs. Each row carries the idempotency_key you sent, so match your records on it.
- Reserve, capture, refund: a 20-clip batch with 3 failures, 2 cancels
Worked example of how a Sume balance moves across a 20-job batch when 3 jobs fail and 2 are canceled while queued: what is held, captured and released.
- Retry a timed-out Omni Flash submit without paying twice (Node)
Node 18+ code that retries a Gemini Omni Flash 1.1 POST to Sume's /v1/videos on timeout or 429 with one Idempotency-Key, so a retry returns the same job.
Written by Sume