Video Generation With the Vercel AI SDK 7 and LLM Gateway
AI SDK video generation now works through LLM Gateway: version 4 of @llmgateway/ai-sdk-provider targets AI SDK 7 and adds llmgateway.video() for experimental_generateVideo. Generate Veo, Seedance, and KLING clips with one API key, including image-to-video, first and last frames, references, and long-running jobs.

The Vercel AI SDK made text, tools, and images feel like one API. Video was the holdout: if you wanted a Veo or Seedance clip from an AI SDK app that routed through LLM Gateway, you left the SDK, posted to /v1/videos yourself, polled the job, downloaded the content, and glued the bytes back in. AI SDK video generation through the gateway now takes one call.
Version 4 of @llmgateway/ai-sdk-provider targets AI SDK 7 and implements the SDK's native video model interface. Same package, same API key, and every video-capable model on the gateway.
Install the AI SDK 7 provider
1pnpm add @llmgateway/ai-sdk-provider@4 ai zod1pnpm add @llmgateway/ai-sdk-provider@4 ai zodCreate an API key in the LLM Gateway dashboard and export it as LLM_GATEWAY_API_KEY. The default llmgateway instance reads it from the environment; createLLMGateway({ apiKey, baseURL }) covers custom keys and self-hosted gateways.
Generate a video
1import { writeFile } from "node:fs/promises";2import { llmgateway } from "@llmgateway/ai-sdk-provider";3import { experimental_generateVideo as generateVideo } from "ai";4
5const { video } = await generateVideo({6 model: llmgateway.video("seedance-2-0"),7 prompt: "A cinematic aerial view of ocean waves at sunrise",8 duration: 8,9 resolution: "1280x720",10 poll: { intervalMs: 5_000, timeoutMs: 600_000 },11 abortSignal: AbortSignal.timeout(600_000),12});13
14await writeFile("video.mp4", video.uint8Array);1import { writeFile } from "node:fs/promises";2import { llmgateway } from "@llmgateway/ai-sdk-provider";3import { experimental_generateVideo as generateVideo } from "ai";4
5const { video } = await generateVideo({6 model: llmgateway.video("seedance-2-0"),7 prompt: "A cinematic aerial view of ocean waves at sunrise",8 duration: 8,9 resolution: "1280x720",10 poll: { intervalMs: 5_000, timeoutMs: 600_000 },11 abortSignal: AbortSignal.timeout(600_000),12});13
14await writeFile("video.mp4", video.uint8Array);Behind that call the provider creates a gateway video job, the SDK polls its status with your poll settings, and the finished file is downloaded through the authenticated content endpoint. The result carries the bytes, the media type, response metadata, and the job ID under providerMetadata.llmgateway.videos. Failed, canceled, and expired jobs throw instead of returning an empty result.
duration and a text prompt are required. resolution maps to the gateway's size and also decides the aspect ratio: 1280x720 is landscape, 720x1280 is portrait. generateAudio maps to audio. The gateway validates the combination and returns 400 for a size or duration the selected model cannot serve.
Image-to-video, frames, and references
The SDK's richer prompt shapes map onto the gateway's video inputs, so the same code covers the different ways models accept guidance:
1const { video } = await generateVideo({2 model: llmgateway.video("seedance-2-0"),3 prompt: {4 image: "https://example.com/first-frame.png",5 text: "Animate the scene with gentle camera motion",6 },7 duration: 5,8 resolution: "1280x720",9 generateAudio: false,10});1const { video } = await generateVideo({2 model: llmgateway.video("seedance-2-0"),3 prompt: {4 image: "https://example.com/first-frame.png",5 text: "Animate the scene with gentle camera motion",6 },7 duration: 5,8 resolution: "1280x720",9 generateAudio: false,10});| SDK option | Gateway field |
|---|---|
prompt.image | image (first frame) |
frameImages | image and last_frame |
inputReferences | reference_images and reference_videos |
n | One independent job per requested video |
providerOptions.llmgateway | Any other field, such as reference audio |
Images can be URLs, base64 data, or raw bytes; video references must be HTTPS URLs with a video media type. aspectRatio, fps, and seed are not forwarded and surface as unsupported-setting warnings rather than being dropped silently. Model-specific rules, such as which models accept frames or references, are enforced by the gateway and documented in the video generation API reference.
Long-running jobs
Video jobs take minutes, and a serverless function may not want to hold the connection. The provider supports the SDK's experimental_startVideo and experimental_getVideoStatus, so one process can submit the job and another can check on it later using the same model and job ID. Aborting stops local polling; the gateway job may keep running. For push-style completion, pass the gateway's callback_url and callback_secret through providerOptions.llmgateway and the gateway signs a webhook when the job finishes.
Picking a model
Model IDs are strings, so anything on the models page with the video filter works. The current families and what they accept:
| Model | Provider | Resolutions | Durations | Frames | References |
|---|---|---|---|---|---|
| Veo 3.1 | google-vertex | 720p, 1080p, 4K | 4, 6, 8, or 10 s | First and last | Images |
| Seedance 2.5 | bytedance | 480p, 720p, 1080p | 4–30 s | First and last | Images, videos, audio |
| Seedance 2.0 | bytedance | 720p, 1080p | 4–15 s | First and last | Images, videos, audio |
| Seedance 2.0 Fast | bytedance | 720p | 4–15 s | First and last | Images, videos, audio |
| Seedance 2.0 Mini | bytedance | 480p, 720p | 4–15 s | First and last | Images, videos, audio |
| Seedance 1.5 Pro | bytedance | 720p, 1080p | 5 or 10 s | None | None |
| KLING v3.0 | atlascloud | 720p, 1080p, 4K | 5 or 10 s | First and last | None |
| KLING v3.0 Turbo | atlascloud | 720p, 1080p | 5 or 10 s | First and last | None |
KLING v3.0 Turbo always generates audio and rejects generateAudio: false; use KLING v3.0 for silent output. Frame inputs and reference inputs cannot be combined in one request. The video generation docs list the exact size strings per model.
What else changed in version 4
Chat, completion, and image models now implement AI SDK 7's v4 model interfaces, including tagged file inputs and outputs. Completion models get corrected default tool-choice handling and proper text-stream lifecycle events. The package ships as ESM with shared runtime classes and type declarations across its entry points, and the test suite runs the same 150 cases in Node and Edge.
Migrating: version 4 requires Node.js 22 or later, ESM imports, and AI SDK 7.0.93 or later. Follow the AI SDK 7 migration guide for the SDK side; the provider's own surface for text and images is unchanged. Stay on @llmgateway/ai-sdk-provider@3 if you are on AI SDK 6.
Getting started
- Try LLM Gateway free and generate your first clip with the code above
- Read the AI SDK docs page for text, streaming, tools, and video in one place
- Generating images with the AI SDK uses the same provider with
llmgateway.image()
One API key for every model.
Route to 200+ models with automatic failover, caching, and real-time cost analytics. Free to start — no credit card required.
Frequently asked questions
- How do I generate video with the Vercel AI SDK?
- Install @llmgateway/ai-sdk-provider@4 with ai and zod, then call experimental_generateVideo with model: llmgateway.video('seedance-2-0'), a prompt, a duration, and a resolution. The provider submits a gateway video job, the SDK polls it, and the result contains the MP4 bytes in video.uint8Array.
- Which video models work with the LLM Gateway AI SDK provider?
- Any video-capable model on LLM Gateway, including Google's Veo 3.1, ByteDance's Seedance 2.5, 2.0, 2.0 Fast, 2.0 Mini, and 1.5 Pro, and KLING v3.0 and v3.0 Turbo. Model IDs are plain strings, so new gateway video models work without a provider update.
- Does the AI SDK 7 provider still support AI SDK 6?
- No. Provider 4.x requires AI SDK 7.0.93 or later, Node.js 22 or later, and ESM imports. Projects on AI SDK 6 should stay on @llmgateway/ai-sdk-provider@3, which keeps receiving text and image support.