Video generation
Start a video job, poll it, and download the finished clip.
Video generation is slow, so every provider returns a job first rather than a video.
videoGeneration()starts the job and returns aVideoJob, usuallyqueuedorin_progress.retrieveVideo()reads the job again.pollVideo()does that until the job iscompletedorfailed.downloadVideo()returns the finished video as bytes, whether the provider handed back a URL or inline data.
import { downloadVideo, pollVideo, videoGeneration } from "any-llm-ts";
const job = await videoGeneration({
model: "together:ByteDance/Seedance-2.0",
prompt: "A yellow rubber duck sits on a wooden table while sunlight slowly moves across it.",
seconds: 5,
resolution: "720p",
aspectRatio: "16:9",
});
const finished = await pollVideo({
provider: "together",
videoId: job.id,
pollInterval: 10,
timeout: 900,
});
if (finished.status === "failed") {
throw new Error(finished.error?.message ?? "video generation failed");
}
const [output] = finished.outputs;
if (output === undefined) throw new Error("completed job has no outputs");
const video = await downloadVideo({ provider: "together", output });
console.log(`${video.byteLength} bytes of ${output.mimeType ?? "video/mp4"}`);A failed job is returned, not thrown, so its error can be read. After timeout seconds (default 600; null waits forever) pollVideo() throws an Error.
The same call works against Gemini by changing the model string and dropping seconds, which Omni Flash does not take:
const job = await videoGeneration({
model: "gemini:gemini-omni-1.1-flash",
prompt: "A yellow rubber duck sits on a wooden table while sunlight slowly moves across it.",
resolution: "720p",
aspectRatio: "16:9",
});Pass either size (WIDTHxHEIGHT) or resolution and aspectRatio, not both.
Providers
| Provider | Notes |
|---|---|
| DeepInfra | Native POST /v1/inference/{model} after reading the model's input schema from GET /models/{model}. Seedance, Wan 3.0, and Wan 2.6 each spell frames, resolution, audio, and generateAudio differently; a field the schema has no name for raises UnsupportedParameterError. A providerOptions value that changes a shared field raises InvalidRequestError. Renders finish inside the request (default timeout 900 seconds), so retrieveVideo only sees jobs started in this process. Pass webhook and completeVideoJob to finish a queued job from its callback. The finished job reports cost and tokens when DeepInfra bills them. |
| Gemini | Gemini Omni Flash through the Interactions API. size, or resolution and aspectRatio, must be 16:9 or 9:16 with a short side of 360, 720, 1080, or 2160 pixels. seconds, negativePrompt, referenceAudios, referenceVideos, and generateAudio raise UnsupportedParameterError. A response_format or generation_config option merges with the shared fields and raises if it changes them. Files API URIs download with the API key. |
| Together | POST /v2/videos and GET /v2/videos/{id} for models such as ByteDance/Seedance-2.0. size maps to width / height, resolution and aspectRatio to resolution / ratio, seconds to a string, and generateAudio to generate_audio. Image, audio, and video inputs go in media: firstFrame / lastFrame as media.frame_images, referenceImages as media.reference_images, referenceAudios as media.audio_inputs, and referenceVideos as media.reference_videos with {video} items. A media you pass in providerOptions or extra_body merges with these; providerOptions.media wins overlapping keys. Together-only options such as fps go in providerOptions. An option that changes a shared field raises InvalidRequestError. Seedance renders fixed resolutions only (for example 864x496, 1280x720, 1920x1080, and their portrait twins); any other WIDTHxHEIGHT is sent, but the job then fails with unsupportedModelResolution. |
All other providers reject video generation with UnsupportedOperationError. OpenAI is among them: the Videos API was removed with no replacement.
Frames and references
const job = await videoGeneration({
model: "gemini:gemini-omni-1.1-flash",
prompt: "A smooth cinematic transition from sunrise to a starry night.",
firstFrame: "https://example.com/sunrise.png",
lastFrame: "data:image/png;base64,....",
referenceImages: ["https://example.com/style.png"],
});Images are URLs, provider file URIs, or data: URLs with base64 content. referenceAudios and
referenceVideos are the same for a soundtrack, lip-sync clip, or motion reference; Gemini rejects
both, and generateAudio.
const job = await videoGeneration({
model: "together:ByteDance/Seedance-2.5",
prompt: "A rapper performs to the beat.",
referenceAudios: ["https://example.com/beat.mp3"],
generateAudio: true,
});DeepInfra can post the finished job to a webhook instead of holding the request open. Pass the
callback body to completeVideoJob; retrieveVideo then reads it back in the same process.
import { completeVideoJob } from "any-llm-ts";
const queued = await videoGeneration({
model: "deepinfra:ByteDance/Seedance-2.0",
prompt: "A yellow rubber duck sits on a wooden table.",
providerOptions: { webhook: "https://hooks.example/done" },
});
const finished = completeVideoJob({
provider: "deepinfra",
payload: callbackBody,
});Capability flags are endpoint-level guidance
A true videoGeneration flag does not guarantee that every model offered by the provider
implements the operation. Validate the selected model against the provider's own documentation.