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.

3 min readSume
All posts

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-Key makes a rerun return the original job instead of a second charge.
  • failed carries an error field; cancelled is the spelling /v1/videos uses.
  • usage.cost on 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.

Gemini Omni Flash 1.1 Sume list price, read 2026-10-08
ResolutionPer second3 s clip10 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

All Developers posts

Written by Sume