Model Capabilities

Video Extension

View as Markdown

Extend an existing video by providing a source video and a text prompt describing what should happen next. The result is a single video that picks up seamlessly from the last frame of the input and continues with the generated content.

  • The input video must have the .mp4 extension and be encoded with .mp4 supported codecs such as H.265 / H.264 / AV1, etc.
  • The input video duration must be between 2 and 15 seconds.
  • The extension duration range is 2–10 seconds (default: 6).
  • The aspect_ratio and resolution parameters are not supported for video extension; the output matches the aspect ratio and resolution of the input, capped at 720p.

The duration parameter controls the length of the extended portion only, not the total output. For example, if your input video is 10 seconds and you set duration to 5, the returned video will be 15 seconds long (10s original + 5s extension).

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)

Video editing uses the /v1/videos/edits endpoint and client.video.generate(video_url=...) in the Python SDK. In the AI SDK, set providerOptions.xai.mode to "edit-video" or "extend-video" and pass providerOptions.xai.videoUrl. The same asynchronous polling pattern applies to both flows, and the AI SDK returns the xAI-hosted output URL in providerMetadata.xai.videoUrl.



Did you find this page helpful?

Last updated: April 2, 2026