TanStack / TanStack/ai

Video duration validation: support template strings (e.g. "6s", "auto") and add snapDuration helper

Open
#538 0 comments 0 reactions 1 assignee View on GitHub

@tombeckenham is already working on this.

Since Sep 17, 2026.

waiting-on: maintainer
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 duration a template-literal-driven type so per-model duration unions are surfaced at compile time (mirroring the OpenAIVideoModelSizeByName/size pattern already used for image dimensions).
  • Introduce a snapDuration helper 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.