Model Capabilities

Video Overview

View as Markdown

The xAI video APIs generate, edit, and extend videos with Grok video models. Video requests are asynchronous: start a request, poll with the returned request ID, and use the completed video URL when it is ready. The xAI SDK and AI SDK handle polling for you.

Image-to-Video

Image + prompt

Animate a still image with a text prompt.

Video Editing

Video + prompt

Modify an existing video while preserving the rest of the scene.

Reference-to-Video

Reference images

Guide a generated video with one or more reference images.

Pricing

Video generation uses per-second pricing. Longer videos cost more, and both duration and resolution affect the total cost. For full pricing details on the grok-imagine-video model, see the models page.

Limitations

  • Maximum duration: 15 seconds for generation, 8.7 seconds for editing input videos, 2-10 seconds for extensions (input must be 2-15 seconds)
  • URL expiration: Generated URLs are temporary
  • Resolutions: 480p or 720p
  • Content moderation: Videos are subject to content policy review

Video Generation

Generate videos from text prompts. Configure duration, aspect ratio, and resolution to match the output format your application needs.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="A glowing crystal-powered rocket launching from the red dunes of Mars, ancient alien ruins lighting up in the background as it soars into a sky full of unfamiliar constellations",
    model="grok-imagine-video",
    duration=10,
    aspect_ratio="16:9",
    resolution="720p",
)

print(response.url)

Image-to-Video

Animate a still image with a text prompt. The source image becomes the starting point for the generated video.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="Make the water crash down and slowly pan out the camera",
    model="grok-imagine-video",
    image_url="https://docs.x.ai/assets/api-examples/video/waterfall-still.png",
    duration=12,
)

print(response.url)

Video Editing

Modify an existing video while preserving the rest of the scene. Use this when you want targeted changes to people, objects, style, or motion in a source video.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="Give the woman a silver necklace",
    model="grok-imagine-video",
    video_url="https://data.x.ai/docs/video-generation/portrait-wave.mp4",
)

print(response.url)

Reference-to-Video

Guide a generated video with one or more reference images. Reference images influence what appears in the video without forcing the first frame to match the input.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="slow zoom in on the white fashion runway stage. then, the model from <IMAGE_1> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_2> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",
    model="grok-imagine-video",
    reference_image_urls=[
        "<IMAGE_URL_1>",
        "<IMAGE_URL_2>",
        "<IMAGE_URL_3>",
    ],
    duration=10,
    aspect_ratio="16:9",
    resolution="720p",
)

print(response.url)

Video Extension

Continue an existing video from its last frame. The returned result combines the original input and the generated extension into one video.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.extend(
    prompt="The shot pans to an over the shoulder perspective. Calm controlled scene.",
    model="grok-imagine-video",
    video_url="<VIDEO_URL>",
    duration=10,
)

print(response.url)

Did you find this page helpful?

Last updated: May 6, 2026