Model Capabilities
Video Editing
Edit an existing video by providing a source video along with your prompt. The model understands the video content and applies your requested changes.
You can provide the source video as a public URL, a base64-encoded data URI, or a file_id from the Files API. See Imagine → Files API Integration for using file_id inputs.
| Requirement | Value |
|---|---|
| Model | grok-imagine-video |
| Source video | .mp4 with a supported codec such as H.264, H.265, or AV1 |
| Source length | Up to 8.7 seconds |
| Output | Same duration, aspect ratio, and resolution as the source, capped at 720p |
duration, aspect_ratio, resolution | Not supported |
grok-imagine-video applies the change you describe and keeps everything else as close to the source as it can. Say what must stay the same, as these prompts do:

import { xai, type XaiVideoModelOptions } from "@ai-sdk/xai";import { experimental_generateVideo as generateVideo } from "ai";const result = await generateVideo({ model: xai.video("grok-imagine-video"), prompt: "Change the color of the woman's dress to red. Keep everything else exactly as in the original, including her face, hands, pose, and the background.", providerOptions: { xai: { mode: "edit-video", videoUrl: "https://media.x.ai/v1/docs/i2v-portrait-wave-4cb4c17c.mp4", pollTimeoutMs: 600000, } satisfies XaiVideoModelOptions, },});const videoUrl = result.providerMetadata?.xai?.videoUrl;console.log(videoUrl);In the Vercel AI SDK, video editing is triggered by setting providerOptions.xai.mode to "edit-video" and passing providerOptions.xai.videoUrl with a source video URL. The prompt describes the desired modifications; duration, aspectRatio, and resolution are ignored because the output inherits these properties from the input video, capped at 720p.
Concurrent Requests
When you need to apply several edits to the same source video, run requests concurrently.
import { xai, type XaiVideoModelOptions } from "@ai-sdk/xai";
import { experimental_generateVideo as generateVideo } from "ai";
const sourceVideo = "https://media.x.ai/v1/docs/i2v-portrait-wave-4cb4c17c.mp4";
const prompts = [
"Give the woman a silver necklace",
"Change the color of the woman's outfit to red",
"Give the woman a wide-brimmed black hat",
];
const results = await Promise.all(
prompts.map(prompt =>
generateVideo({
model: xai.video("grok-imagine-video"),
prompt,
providerOptions: {
xai: {
mode: "edit-video",
videoUrl: sourceVideo,
pollTimeoutMs: 600000,
} satisfies XaiVideoModelOptions,
},
}),
),
);
prompts.forEach((prompt, i) => {
console.log(`${prompt}: ${results[i].providerMetadata?.xai?.videoUrl}`);
});
Related
- Video Generation — Generate videos from text prompts
- Image-to-Video — Animate a still image
- Video Extension — Extend existing videos
- API Reference — Full endpoint documentation
- Imagine API Landing Page — Showcase of the Imagine API in action
Last updated: October 9, 2026