Skip to content
Dashboard

Grok Imagine Video 1.5

Grok Imagine Video 1.5 is xAI's image-to-video generation model. It animates a starting image and generates synchronized audio in a single pass, available through Vercel AI Gateway. Your use is subject to xAI's Terms & Privacy Policies.

image-to-videoreference-to-videotext-to-video
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({
model: 'xai/grok-imagine-video-1.5',
prompt: 'A serene mountain lake at sunrise.'
});
Read docs

Getting started

Generate videos with Grok Imagine Video 1.5 using the experimental_generateVideo function from AI SDK 6 or later. AI Gateway handles routing and polls until the video is ready.

Install the AI SDK (pnpm add ai dotenv), create an API key from the API Keys page, and set it as AI_GATEWAY_API_KEY in your environment. Full setup is covered in the video generation quickstart.

index.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'xai/grok-imagine-video-1.5',
prompt: {
image: 'https://example.com/cat.png',
text: 'The cat slowly turns its head and blinks',
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);

Top-level parameters

Load the supported top-level parameters: prompt.image, prompt.text, duration, and aspectRatio.

top-level-params.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'xai/grok-imagine-video-1.5',
prompt: {
image: 'https://example.com/cat.png',
text: 'The cat slowly turns its head and blinks',
},
duration: 5,
aspectRatio: '16:9',
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);
ParameterTypeRequiredDescription
promptstringNoText description of the video to generate.
durationnumberNoVideo length in seconds. 1-15 seconds.
resolutionstringNoResolution ('854x480', '1280x720', '1920x1080').
aspectRatiostringNoAspect ratio ('1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3').
frameImagesArray<{ image: string | Buffer; frameType: 'first_frame' }>NoOpening frame of the clip, as a single first_frame entry. Replaces prompt.image and wins when both are set. Grok does not interpolate to an ending image, so a last_frame entry is ignored with a warning.
inputReferencesArray<string | Buffer>NoOne to seven reference images that Grok builds a new scene from rather than animating. Passing them selects reference-to-video mode automatically. Images only — a video reference is ignored with a warning, so use mode: 'extend-video' to continue from a video.

Input limits

InputFormatsSourcesMax countMax sizeLimits
Imageurl, base647
Audiourl

Provider options

Pass every Grok image-to-video option under providerOptions.xai.

provider-options.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'xai/grok-imagine-video-1.5',
prompt: {
image: 'https://example.com/cat.png',
text: 'The cat slowly turns its head and blinks',
},
duration: 5,
providerOptions: {
xai: {
resolution: '720p',
pollIntervalMs: 5000,
pollTimeoutMs: 600000,
},
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);

Pass Grok-specific options under providerOptions.xai in your generateVideo call.

ParameterTypeRequiredDescription
referenceImageUrlsstring[]NoOne to seven reference image URLs for reference-to-video, which generates a new scene from the references rather than animating them. Legacy alternative to the top-level inputReferences, used only when inputReferences is omitted.
resolution'480p' | '720p'NoVideo resolution. Defaults to 480p.
pollIntervalMsnumberNoHow often to check task status. Defaults to 5000.
pollTimeoutMsnumberNoMaximum wait time. Defaults to 600000 (10 minutes).

Mode selection and frames

Editing, extension, and reference-to-video are mutually exclusive. Passing providerOptions.xai.videoUrl selects editing, and passing inputReferences selects reference-to-video; set providerOptions.xai.mode to choose explicitly.

The top-level parameters win over their provider-option equivalents: a first_frame in frameImages overrides prompt.image, and inputReferences overrides providerOptions.xai.referenceImageUrls.

Grok does not interpolate between a first and last frame. A last_frame entry in frameImages is ignored with a warning — use mode: 'extend-video' to continue from the end of an existing clip instead.

frameImages takes priority over references: when it is set, reference-to-video is not auto-selected.

Image to video

Animate a static image by passing prompt.image (a URL) with an optional prompt.text describing the motion. The output defaults to the input image’s aspect ratio; setting aspectRatio overrides it and stretches the image.

grok-image-to-video.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'xai/grok-imagine-video-1.5',
prompt: {
image: 'https://example.com/cat.png',
text: 'The cat slowly turns its head and blinks',
},
duration: 5,
providerOptions: {
xai: {
pollTimeoutMs: 600000,
},
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);

Reference to video

Generate a new scene from reference images passed through the top-level inputReferences. The references guide visual elements in the output rather than becoming the first frame, and passing them selects reference-to-video mode automatically. Refer to each one in the prompt with <IMAGE_1>, <IMAGE_2>, and so on.

reference-to-video.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'xai/grok-imagine-video-1.5',
prompt:
'The comic cat from <IMAGE_1> and the comic dog from <IMAGE_2> ' +
'are having a playful chase through a sunlit park. ' +
'Cinematic slow-motion, warm afternoon light.',
inputReferences: [
'https://example.com/comic-cat.png',
'https://example.com/comic-dog.png',
],
duration: 8,
aspectRatio: '16:9',
providerOptions: {
xai: {
pollTimeoutMs: 600000,
},
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);