Snap a requested video length to supported durations in Python
Veo 3.1 accepts only 4, 6 or 8 seconds. A short Python helper snaps any requested length to a model's supported_durations list from GET /v1/videos/models.

Snap the requested length to the nearest value in the model's duration list before you submit, so an odd request such as 7 seconds does not fail. Veo 3.1 on the Gemini API accepts 4, 6 or 8 seconds, and Sume publishes each video model's list as supported_durations at GET /v1/videos/models.
Limits differ by model
Duration limits are not uniform. The Veo guide lists 4, 6 and 8 seconds, and says 8 seconds is required for 1080p, 4K and reference images. On Sume, the docs list seedance-2.5 at 4 to 30 seconds, wan-3.0 at 2 to 30, minimax-h3 at 5 to 15 and gemini-omni-flash-1.1 at 3 to 10.
| Model | Allowed lengths | Source |
|---|---|---|
| Veo 3.1 (Gemini API) | 4, 6 or 8 s | Google Veo guide |
| seedance-2.5 (Sume) | 4 to 30 s | Sume video docs |
| wan-3.0 (Sume) | 2 to 30 s | Sume video docs |
| minimax-h3 (Sume) | 5 to 15 s | Sume video docs |
| gemini-omni-flash-1.1 (Sume) | 3 to 10 s | Sume video docs |
The helper
The function picks the closest allowed value and, on a tie, the longer one so a caption or voiceover is not cut. The block runs as written and needs no network access.
def snap_duration(requested, supported):
if not supported:
raise ValueError('model lists no supported_durations')
return min(supported, key=lambda d: (abs(d - requested), -d))
def main():
veo = [4, 6, 8]
seedance = list(range(4, 31))
for want in (3, 5, 7, 12):
print(want, '->', snap_duration(want, veo), snap_duration(want, seedance))
if __name__ == '__main__':
main()Reading the list from Sume
To use live data, call GET /v1/videos/models with your bearer key, find your model by id, and pass its supported_durations to the helper. Do the same check for supported_resolutions and supported_aspect_ratios. The request shape is in the video docs. If you send a value the model rejects you get a 400, so snapping first saves a round trip.
Sources
Related posts
More in Developers
- Sora ended in two steps: app in April, API on September 24
OpenAI's docs say the Sora API shut down Sep 24, 2026 with no direct replacement. A help-center snippet dates the app and web end at Apr 26. What to inventory.
- Sora replacement smoke test: one prompt, three Sume models, in Python
A short Python script that sends the same 5-second prompt to seedance-2.5, wan-3.0 and gemini-omni-flash-1.1 on Sume and prints status, cost and URLs.
- Sort your MCP tool allowlist: stable order keeps the prompt cache warm
MCP 2026-07-28 asks servers for ttlMs, cacheScope and a deterministic tool order. On the client, sort your media tool allowlist the same way. Python snippet.
- Split a narration script by model character limit: Python
ElevenLabs lists a 40,000 character limit for Flash v2.5 and 10,000 for v4 and v4 Turbo. A Python splitter that cuts on sentences, with a concat step on Sume.
Written by Sume