Anime series by API: a job-queue pattern on Sume

Pika's API Club spotlights show members making anime and dramas by API. A series needs a queue: idempotent submits, polling, and a webhook as a fast path.

4 min readSume
All posts

To build a series by API, treat every shot as a job in a queue: submit with a stable idempotency key, record the job id, and collect the result by webhook or polling. The Pika blog of Sep 24, 2026 spotlights three API Club members making anime, dramas and tools; the queue below uses Sume's documented video endpoint.

Why a queue

A series is dozens of shots. A crash halfway through a script that submits shots in a loop leaves you unsure which were paid for. The Sume video route supports Idempotency-Key, and a replay returns the original job, so deriving the key from episode and shot number makes the loop safe to restart.

The Sume endpoints

Job-queue calls on Sume (Sume docs, read 2026-10-03)
StepCallNotes
SubmitPOST /v1/videosSend Idempotency-Key; response has id and polling_url
Push resultcallback_url in the bodyHTTPS only; signed job event
PollGET /v1/videos/{jobId} or GET /v1/jobs/{id}/statusStop on completed or failed
DownloadGET /v1/videos/{jobId}/contentindex defaults to 0

A small runnable queue

This script submits shots with deterministic keys, then polls each polling URL. Run it twice and the second run reuses the same jobs.

import os, time, requests

BASE = "https://api.sume.com/v1/videos"
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
shots = {
    "ep01-s01": "Anime style: a courier runs across neon rooftops at dusk",
    "ep01-s02": "Anime style: she stops at the edge and looks at the skyline",
}

jobs = {}
for key, prompt in shots.items():
    r = requests.post(BASE, json={"model": "sume/auto", "prompt": prompt, "aspect_ratio": "16:9", "duration": 5},
                      headers={**H, "Idempotency-Key": key})
    r.raise_for_status()
    jobs[key] = r.json()["polling_url"]

while jobs:
    for key, url in list(jobs.items()):
        s = requests.get(url, headers=H).json()
        if s["status"] in ("completed", "failed"):
            print(key, s["status"])
            del jobs[key]
    time.sleep(30)

Webhook as the fast path

Pass callback_url and Sume POSTs a signed terminal job event. Return a 2xx after storing it, use job_id as your idempotency key, and keep polling as a backup, since ten failed delivery attempts do not change the job's real state. Sume does not claim character consistency across shots from this pattern; that is a prompting and reference-image question, not a queue question.

Sources

Related posts

More in Use cases

All Use cases posts

Written by Sume