Python video fallback ladder when a model id is gone

A short Python ladder posts to Sume's /v1/videos with the first id that exists and moves on after a 404 model_not_found. Needs SUME_API_KEY, and runs.

4 min readSume
All posts

How do you keep a video job from failing when a model id disappears? Put your preferred ids in a list and try each in order. Sume's video API returns 404 model_not_found for an unknown id, so one 404 is your signal to try the next. The script below does that and stops at the first accepted job.

The ladder

It exits when SUME_API_KEY is empty. The prompt, resolution and duration are placeholders; pick values every id in your list supports, such as 5 seconds at 720p.

import os, sys, httpx

key = os.environ.get("SUME_API_KEY", "")
if not key:
    sys.exit("Set SUME_API_KEY first")

LADDER = ["gemini-omni-flash-1.1", "seedance-2.5", "wan-3.0"]
body = {"prompt": "A paper boat on a rainy street",
        "duration": 5, "resolution": "720p"}
hdr = {"Authorization": f"Bearer {key}"}

for model in LADDER:
    r = httpx.post("https://api.sume.com/v1/videos",
                   headers=hdr, json={**body, "model": model},
                   timeout=60)
    if r.status_code == 404:
        print("skip", model)
        continue
    r.raise_for_status()
    print("accepted", model, r.json().get("id"))
    break
else:
    sys.exit("no model in the ladder was accepted")

What the ladder does not cover

A 404 is only one failure. A 400 unsupported_capability means the model cannot do what you asked, and a 402 insufficient_credits means no other id will work either, so the loop raises on those instead of moving on. Because raise_for_status runs after the 404 check, those codes stop the script with a clear error.

Order the ladder by what you need, not by price: put the model whose look you want first. Sume bills the list price times 1.25, rounded up to cents, so a fallback can cost more or less than the first choice.

Failure handling in the ladder, read 2026-10-06
StatusMeaning in Sume docsLadder action
404 model_not_foundId is not listedTry next id
400 unsupported_capabilityModel cannot do the requestStop and fix the request
402 insufficient_creditsBalance too lowStop

Next steps

Poll GET /v1/videos/{id} until the status is completed, then download from GET /v1/videos/{id}/content. Statuses map from queued to pending and processing to in_progress, so a loop that waits on pending and in_progress is enough.

Keeping the ladder honest

Test each rung once with a short clip so you know every id accepts your body. Models differ: Omni allows 3 to 10 seconds and 16:9 or 9:16 only, Wan 3.0 starts at 2 seconds, and Seedance 2.5 starts at 4. The 5 second, 720p body above is inside all three, which is why it works as a template. Add fields such as aspect_ratio only after checking they are valid for every id in the ladder, because an unsupported value on one rung will end the loop at that rung with a 400.

The script needs httpx, installed with pip. The request is a plain JSON POST with a bearer key, matching the OpenRouter-style shape Sume documents for /v1/videos, and the job id in the response is what you poll next. Log which rung accepted, so a quiet drift to a fallback id shows up in your metrics instead of in a surprised invoice.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume