Skip to content
Dashboard

Video Generation with AI Gateway

Product, AI Gateway

Link to headingTwo ways to get started

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'xai/grok-imagine-video',
prompt: 'A golden retriever catching a frisbee mid-air at the beach',
});

Link to headingFour initial video models; 17 variations

Link to headingUnderstanding video requests

Link to headingGeneration types

Link to headingText-to-video

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'klingai/kling-v2.6-t2v',
prompt: `Wide shot of a rocket lifting off from launch pad at dawn.
Massive plume of orange fire and white smoke billows outward
from the base. The rocket rises slowly at first, engines blazing,
then accelerates upward. Pink and orange sunrise sky
in the background. Ocean visible in the distance.`,
aspectRatio: '16:9',
duration: 5,
providerOptions: {
klingai: {
mode: 'pro',
sound: 'on',
},
},
});

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'google/veo-3.1-generate-001',
prompt: `Close-up of a great horned owl turning its head slowly.
Enormous yellow eyes with intricate iris detail.
Every feather texture visible, from soft facial disc to ear tufts.
The owl blinks once, deliberately.`
aspectRatio: '16:9',
});

Link to headingImage-to-video

iconst { videos } = await generateVideo({
model: 'klingai/kling-v2.6-i2v',
prompt: {
image: blackHoodie,
text: `The orange tabby cat walks slowly across the black hoodie.
Warm natural light. Cozy lifestyle scene. Smooth, cinematic.`,
},
duration: 5,
providerOptions: {
klingai: { mode: 'pro' },
},
});

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'alibaba/wan-v2.6-i2v',
prompt: {
image: 'https://your-storage.com/coffee-pour.png',
text: `Coffee swirls gently in the cup, steam rises slowly,
warm morning light shifts subtly`,
},
resolution: '1280x720',
duration: 3,
});

Link to headingFirst and last frame

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'klingai/kling-v3.0-i2v',
prompt: {
image: startFrameDataUrl, // Empty room
text: `Smooth cinematic transition: The empty loft fills with furniture.
A green velvet sofa fades into view, followed by a wooden coffee table.
Potted plants rise from the floor. A patterned rug materializes.
Framed artwork appears on the walls. Bookshelves on the back wall.
Gentle, seamless transformation.`,
},
duration: 5,
providerOptions: {
klingai: {
lastFrameImage: endFrameDataUrl, // Furnished room
mode: 'std',
},
},
});

Link to headingReference-to-video

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'alibaba/wan-v2.6-r2v-flash',
prompt:
`character1 and character2 are playing together on the beach in San Francisco
with the Golden Gate Bridge in the background, sunny day, waves crashing`,
resolution: '1280x720',
duration: 5,
providerOptions: {
alibaba: {
referenceUrls: [shibaImage, yorkieImage],
},
},
});

Link to headingVideo Editing

import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: 'xai/grok-imagine-video',
prompt: `Transform into watercolor painting style, soft flowing brushstrokes,
paint bleeding at edges, delicate washes of color, artistic and dreamlike`,
providerOptions:
xai: {
videoUrl: dogVideo,
},
},
});

Link to headingGet started