Skip to content
Dashboard

Grok Imagine

Grok Imagine is SpaceXAI's video generation model. It creates video clips from text prompts and images with motion, generated audio, and lip-sync, available through Vercel AI Gateway.

View API reference
Price
$0.05, Per second
Lowest available configuration
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({
model: 'spacexai/grok-imagine-video',
prompt: 'A serene mountain lake at sunrise.'
});
Read docs

Copy link to headingPlayground

Try out Grok Imagine by SpaceXAI. Usage is billed to your team at API rates. Free users (those who haven't made a payment) get $5 of credits every 30 days.

spacexai logo
Images(optional)
Add up to 5 images
Video to edit(optional)
Prompt(optional)

Duration8s
1s15s
Resolution
Aspect ratio
Videos to generate
spacexai logo

Your generated video will appear here.

Copy link to headingProviders

Route requests across multiple providers. Copy a provider slug to set your preference. Visit the docs for more info. Using a provider means you agree to their terms, listed under Legal.

Provider
Input
Output
Capabilities
ZDR
No Training
Free Tier
Release Date
$0.002/img+1 more
$0.05/sec+1 more
01/28/2026

Getting started

Generate videos with Grok Imagine 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: 'spacexai/grok-imagine-video',
prompt: 'A chicken flying into the sunset in the style of 90s anime',
});
// 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, aspectRatio, duration, and resolution.

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: 'spacexai/grok-imagine-video',
prompt: 'A chicken flying into the sunset in the style of 90s anime',
aspectRatio: '16:9',
duration: 5,
resolution: '1280x720',
});
// 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').
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
Imagejpg, jpeg, png, webp, gif, avifurl, base64, buffer5
Videourl12-8.7s

Provider options

Pass Grok-specific options under providerOptions.xai. videoUrl switches the call into video-editing mode (where duration, aspectRatio, and resolution are ignored), so it has its own example below.

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: 'spacexai/grok-imagine-video',
prompt: 'A chicken flying into the sunset in the style of 90s anime',
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
resolution'480p' | '720p'NoNative resolution format. Alternative to the standard resolution parameter.
videoUrlstringNoURL of a source video. With mode: 'edit-video' (or no mode) the call edits it; with mode: 'extend-video' the clip continues from its last frame. Either way duration, aspectRatio, and resolution are ignored. See the video-editing quirk below.
mode'edit-video' | 'extend-video' | 'reference-to-video'NoSelects the operation explicitly. Omit it for standard generation from a text prompt, prompt.image, or frameImages. Leaving it out while passing videoUrl or inputReferences still works, and is treated as editing or reference-to-video respectively.
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.
pollIntervalMsnumberNoHow often to check task status. Defaults to 5000.
pollTimeoutMsnumberNoMaximum wait time. Defaults to 600000 (10 minutes).

Resolution: two ways

You can set the output resolution two ways: the top-level resolution parameter accepts 854x480 (480p) or 1280x720 (720p), while providerOptions.xai.resolution accepts the native 480p or 720p form. They map to the same two resolutions.

The docs do not specify precedence if you set both, so set only one to avoid ambiguity. providerOptions.xai.resolution is the provider-native control; prefer it when you want to be explicit, or use the top-level resolution for parity with other video models.

Because the top-level resolution is a pixel dimension and aspectRatio is an independent shape control, avoid pairing values that disagree (for example aspectRatio: '1:1' with resolution: '1280x720'). Match the resolution to the ratio, or set the native providerOptions.xai.resolution tier so only aspectRatio controls the shape.

Video editing

Pass providerOptions.xai.videoUrl with a source video URL to edit an existing video instead of generating a new one. The prompt then describes the edits to apply.

The maximum input duration is listed in the Input limits table. The output matches the input video's aspect ratio and resolution, up to 720p (a 1080p input is downsized to 720p).

When editing, the duration, aspectRatio, and resolution parameters are not supported and are ignored.

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: 'spacexai/grok-imagine-video',
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: 'spacexai/grok-imagine-video',
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);

Video editing

Edit an existing video with a text prompt. Provide the source video as providerOptions.xai.videoUrl (input duration limits are in the Input limits table); output matches the input video’s aspect ratio and resolution, up to 720p. The duration, aspectRatio, and resolution parameters are not supported when editing.

video-editing.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'spacexai/grok-imagine-video',
prompt: 'Give the person sunglasses and a hat',
providerOptions: {
xai: {
videoUrl: 'https://example.com/source-video.mp4',
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);

Copy link to headingMore models by SpaceXAI

Model
Context
Latency
Throughput
Input
Output
Cache
Web Search
Capabilities
Providers
ZDR
No Training
Free Tier
Release Date
500K
$2/M+1 more
$6/M+1 more
Read$0.50/M
$5/K
+1
xai logo
08/12/2026
500K
$2/M+1 more
$6/M+1 more
Read$0.30/M
$5/K
+3
xai logo
07/08/2026
1M
$1.25/M+1 more
$2.50/M+1 more
Read$0.20/M
$5/K
+3
vertex logo
xai logo
04/30/2026
2M
$1.25/M+1 more
$2.50/M+1 more
Read$0.20/M
$5/K
+2
vertex logo
xai logo
03/10/2026
1M
$0.20/M
$0.50/M
Read$0.05/M
+1
vertex logo
11/19/2025
1M
$0.20/M
$0.50/M
Read$0.05/M
+2
vertex logo
11/19/2025

Copy link to headingAbout Grok Imagine

Grok Imagine is SpaceXAI's video generation model, released January 28, 2026 and available through Vercel AI Gateway. It generates video clips from text descriptions and static images with motion, instruction following, and support for complex prompts and follow-up instructions to refine scenes.

The model supports three primary generation modes: text-to-video (creating clips from text descriptions), image-to-video (generating motion from static images), and video editing (modifying existing video content through style changes, object replacement, and scene alterations). It also generates audio timed to the video with lip-sync, so you can skip separate voice recording for many workflows. Grok Imagine produces short clips quickly enough for iterative creative workflows. You can call it from the AI SDK's generateVideo function or the v0 Grok Creative Studio. Video generation is currently available to Pro and Enterprise plan subscribers and paid AI Gateway users.

Copy link to headingWhat To Consider When Choosing a Provider

  • Configuration: Video generation is currently limited to Pro and Enterprise plans, as well as paid AI Gateway users. Verify your plan supports video generation before integrating.
  • Configuration: Grok Imagine understands follow-up instructions to tweak scenes. Use iterative prompting to refine output rather than trying to get the perfect result in a single generation.
  • Zero Data Retention: Zero Data Retention is offered on a per-provider and model basis. See the documentation for details.
  • Authentication: AI Gateway authenticates requests using an API key or OIDC token. You do not need to manage provider credentials directly.

Copy link to headingWhen to Use Grok Imagine

Best for

  • Marketing and social media video content: Where custom clips are needed at scale without traditional video production
  • Product demos and explainer videos: That visualize concepts, features, or workflows through generated scenes
  • Creative prototyping and storyboarding: Teams iterate on visual concepts before committing to full production
  • Content creation pipelines: That generate short video assets programmatically for personalization or A/B testing
  • Lip-synced video with native audio: For talking-head content, presentations, or character-driven narratives

Consider alternatives when

  • Static image generation: Grok Imagine Image or Grok Imagine Image Pro handles the task without video overhead
  • Long-form video production: Traditional editing tools provide more control over extended content
  • Free-tier usage: Video generation currently requires a paid plan

Grok Imagine brings AI video generation into the Vercel AI Gateway ecosystem. It supports text-to-video, image-to-video, video editing, and audio in one pipeline. Iterative prompting and short clip latency fit production workflows that need custom video without full traditional production.

Copy link to headingFrequently Asked Questions

  • What generation modes does Grok Imagine support?

    Three modes: text-to-video (creating clips from descriptions), image-to-video (animating static images), and video editing (modifying existing videos through style changes, object replacement, and scene alterations).

  • Does Grok Imagine generate audio?

    Yes. Grok Imagine generates audio in the clip with lip-sync, so you often don't need separate voice recording or dubbing.

  • How fast does Grok Imagine generate video?

    Generation is fast enough for iteration in most setups; exact time depends on length, resolution, and load. Expect short clips, not long renders.

  • What plans support video generation?

    Pro and Enterprise plan subscribers and paid AI Gateway users.

  • How do I authenticate with Grok Imagine through Vercel AI Gateway?

    Use your Vercel AI Gateway API key with spacexai/grok-imagine-video as the model identifier. You can integrate through the AI SDK's generateVideo function or the v0 Grok Creative Studio.

  • Can I refine generated videos with follow-up prompts?

    Yes. Grok Imagine understands follow-up instructions to tweak scenes, adjust styles, and modify content. Use iterative prompting to refine output.

  • Does Vercel AI Gateway support Zero Data Retention for Grok Imagine?

    Zero Data Retention is not currently available for this model. Zero Data Retention is offered on a per-provider basis. See https://vercel.com/docs/ai-gateway/capabilities/zdr for details.

Your use is subject to SpaceXAI's Terms & Privacy Policies.