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.

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.
| Field | Type | Preflight use |
|---|---|---|
id | string | The value you send as model |
supported_durations | integers, whole seconds | Reject a duration not in the list |
supported_resolutions | strings such as 720p | Reject an unlisted resolution |
supported_aspect_ratios | strings such as 16:9 | Reject an unlisted aspect ratio |
supported_frame_images | first_frame, last_frame | Decide whether an end frame is allowed |
supported_input_references | image_url, video_url, audio_url | Decide which reference types are allowed |
generate_audio | boolean | Whether 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
- Virtual try-on API: which Sume call returns an image, which a video
Need a try-on photo or a try-on clip? On Sume the two catalog try-on Formats return video; a still comes from the image API. The table, plus one call for each.
- Test a webhook endpoint before go-live: a Sume CI gate (Python)
Use POST /v1/webhooks/test-deliveries to fire a signed webhook.test at your deployed URL and fail the deploy unless it answers 2xx. Python script included.
- Zod 4 discriminated union for Sume job and run webhooks (TypeScript)
Parse Sume job.* and format.run.terminal webhooks with one Zod 4 discriminatedUnion: typed branches, degraded runs, oversized receipts. Tested with Zod 4.
- Zod 4 toJSONSchema to Sume output_schema: nullable, not optional
z.toJSONSchema works for a Sume Format output_schema if you use nullable instead of optional. A tested table of what passes and what the validator rejects.
Written by Sume