Validate video duration and resolution in Python before you submit

Fetch GET /v1/videos/models and check duration, resolution and aspect_ratio per model in about 25 lines of Python, before a Sume video job fails.

5 min readSume
All posts

Before you submit a Sume video job, fetch GET /v1/videos/models once and check your duration, resolution and aspect_ratio against the model's supported_durations, supported_resolutions and supported_aspect_ratios arrays. A request outside those lists is an invalid combination for that model, and checking it locally gives your user an immediate message instead of a failed job. The Python below does that in under 30 lines with requests.

The catalog fields come from Sume's Video generation docs, read on 2026-10-03.

What does the catalog return for each model?

Each entry in the data array has an id to pass as model, plus the capability arrays. The docs show seedance-2 with durations 4 through 15, resolutions 480p, 720p and 1080p, and six aspect ratios, and a supported_sizes value that can be null. A null or empty list means the catalog states no restriction for that field, so the checker below skips it rather than rejecting every value.

Catalog fields a preflight check reads, from Sume docs, read 2026-10-03
FieldTypePreflight use
idstringThe value you send as model
supported_durationsintegers, whole secondsReject a duration not in the list
supported_resolutionsstrings such as 720pReject an unlisted resolution
supported_aspect_ratiosstrings such as 16:9Reject an unlisted aspect ratio
supported_frame_imagesfirst_frame, last_frameDecide whether an end frame is allowed
supported_input_referencesimage_url, video_url, audio_urlDecide which reference types are allowed
generate_audiobooleanWhether the model can make audio

What does the checker look like?

The script loads the catalog into a dictionary keyed by model id, then returns a list of problems instead of raising, so a caller can show all of them at once. Set SUME_API_KEY first. The final lines ask for a 20 second seedance-2 clip, which the catalog row above does not list, so it prints a message naming the allowed durations.

import os, requests

H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
BASE = "https://api.sume.com"

def load_catalog():
    r = requests.get(f"{BASE}/v1/videos/models", headers=H, timeout=30)
    r.raise_for_status()
    return {m["id"]: m for m in r.json()["data"]}

def preflight(cat, model, duration, resolution, aspect_ratio):
    m = cat.get(model)
    if m is None:
        return [f"unknown model {model}"]
    errs = []
    for key, val, field in [
        ("supported_durations", duration, "duration"),
        ("supported_resolutions", resolution, "resolution"),
        ("supported_aspect_ratios", aspect_ratio, "aspect_ratio"),
    ]:
        allowed = m.get(key)
        if allowed and val not in allowed:
            errs.append(f"{model}: {field} {val!r} not in {allowed}")
    return errs

if __name__ == "__main__":
    cat = load_catalog()
    print(preflight(cat, "seedance-2", 20, "1080p", "16:9"))

What can a catalog check not catch?

It validates shape, not content. Rules that depend on the combination of inputs live in the Router: Kling 3 rejects reference_*_urls, and Gemini Omni Flash 1.1 rejects generate_audio: false. Where a model also has per-model rules like these, the job still comes back with a structured error, so keep your failure handling from the fallback post.

It also cannot know whether a media URL is reachable or the right length. Probe your inputs with video inspect when they matter.

  • Cache the catalog for the length of a batch, not forever; models and limits change.
  • Report every failed field at once, not only the first.
  • Treat a missing model id as a stop, not a retry.
  • Re-run the check whenever you switch models in a fallback chain, since each model has its own lists.

Should I check on every request?

One catalog fetch per process or per batch is enough. The check is a pure function over the dictionary, so it adds no latency per job. For choosing the model in the first place, see which Sume video model for the inputs you have, and for the duration edge see the shortest clip floors.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume