Video duration validation: support template strings (e.g. "6s", "auto") and add snapDuration helper
@tombeckenham is already working on this.
Since Sep 17, 2026.
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 331
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 160
Description
Spinning out a follow-up flagged in PR #409 review (https://github.com/TanStack/ai/pull/409#discussion_r2218485017).
The current validateVideoSeconds hook in OpenAICompatibleVideoAdapter (and concrete subclasses like OpenAIVideoAdapter) treats seconds as a number | string runtime value but the type system doesn't enforce the per-model literals each provider actually accepts.
We really need to change the duration validation. Many models support strings like "6s" instead of the number 6. Some take the string "auto". The duration thing is one of the hardest parts of doing video... it's as hard as the sizes in images. I'll add an issue for it. I think duration needs to be a template type, but we might also want to think about creating a snapDuration method. — @tombeckenham
Scope
- Make
durationa template-literal-driven type so per-model duration unions are surfaced at compile time (mirroring theOpenAIVideoModelSizeByName/sizepattern already used for image dimensions). - Introduce a
snapDurationhelper that maps user-supplied durations (number,\"6s\",\"auto\", etc.) to the value the provider actually wants — symmetrically with how some image providers want a string and some a number. - Audit current providers (Sora-2, Grok video, future Gemini/Veo) for the duration vocabulary they each accept and lock the per-model unions in
model-meta.
Out of scope for this issue
Memory bounding for downloaded video buffers — see the separate "large media uploader" follow-up.
cc @tombeckenham
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.