Huey task that polls an AI video job with schedule(delay=...)
A Huey task reads Sume's job status once and reschedules itself with task.schedule(delay=...) from next_poll_after_seconds, so no worker thread sleeps.

Huey is a small Python task queue, and polling a video render with it is two lines: call the task, and when the job is not terminal call poll.schedule(args=(job_id, n + 1), delay=wait). The task reads Sume's GET /v1/jobs/{id}/status once. terminal ends the chain, and next_poll_after_seconds provides the wait (Sume jobs guide, read 2026-10-06).
The clip in this example is MiniMax H3 at 768p for 6 seconds. Sume bills H3 768p at $0.075 per second, so the clip is $0.45.
What is the full module?
Run huey_consumer.py tasks.huey. Huey's retries option covers HTTP errors; the poll chain counts attempts itself.
import os
import requests
from huey import RedisHuey
huey = RedisHuey("clips")
API = "https://api.sume.com"
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
@huey.task()
def submit(prompt: str, key: str):
r = requests.post(f"{API}/v1/videos", timeout=30,
headers={**H, "Idempotency-Key": key},
json={"model": "minimax-h3", "prompt": prompt,
"duration": 6, "resolution": "768p"})
r.raise_for_status()
poll.schedule(args=(r.json()["id"], 0), delay=15)
@huey.task(retries=3, retry_delay=30)
def poll(job_id: str, n: int):
r = requests.get(f"{API}/v1/jobs/{job_id}/status", headers=H, timeout=30)
r.raise_for_status()
s = r.json()
if s["terminal"]:
return s["sume_status"]
if n < 120:
poll.schedule(args=(job_id, n + 1),
delay=s.get("next_poll_after_seconds") or 15)What does H3 cost at the other sizes?
| Output | Per second | 6-second clip |
|---|---|---|
| 480p | $0.0625 | $0.375 |
| 768p | $0.075 | $0.45 |
| 2K upscale | $0.1625 | $0.975 |
| 4K upscale | $0.20 | $1.20 |
Does a retry of the poller bill a second clip?
No, as long as the poller only reads. Keep the paid POST /v1/videos in a separate step with an Idempotency-Key you own, and let the poller use GET /v1/jobs/{id}/status. A client-side give-up never cancels the render; Sume's jobs guide says the job keeps running, so store the job id and read it again later instead of submitting a second time.
Sources
Related posts
More in Developers
- Idempotency key for transcription: hash the request, avoid 409
Derive the Sume STT Idempotency-Key from a hash of audio_url, language and duration. A retry returns the same job. A changed body under that key is a 409.
- Ideogram 4.5 low to high on one order: new Idempotency-Key or a 409
A reused Idempotency-Key with a different payload returns 409 idempotency_conflict. Key on order id plus a payload hash so a quality change is a new job.
- Keep a series voice consistent: pin model, voice, speed and volume
A series sounds the same only if every episode sends the same TTS settings. Keep one profile in code, pin a model id, and send it with each Sume request.
- Same volume every Shorts episode: gain_db, duck_db, one music bed
Sume does not measure loudness. To keep a series consistent, pin audio.gain_db, soundtrack gain_db and duck_db in one function with one bed. Python plan loop.
Written by Sume