Skip to main content

Overview

Generate videos directly in chat using AI models. Users describe what they want and the model produces a short video clip, which is then playable inline.

Quick Start

Toggle in chat.config.ts:
features: {
  videoGeneration: true, // Requires BLOB_READ_WRITE_TOKEN
}
Video generation requires BLOB_READ_WRITE_TOKEN since generated videos are uploaded to Vercel Blob storage.
Configure the default video model:
models: {
  defaults: {
    video: "xai/grok-imagine-video",
  },
}

Parameters

The tool accepts the following inputs:
ParameterTypeDefaultDescription
promptstringDescriptive text for the video
aspectRatio"16:9" | "9:16" | "1:1""16:9"Output aspect ratio
durationSecondsnumber (1–10)5Length of the generated video
The LLM fills in these parameters automatically based on the user’s request.

Architecture

Follows the Tool Part pattern:
lib/ai/tools/generate-video.ts → components/part/generate-video.tsx

Tool Output

return { videoUrl: result.url, prompt };
The generated video is uploaded to blob storage and the URL returned. Supported container formats are mp4, webm, and mov, resolved from the response media type.

UI States

StateShows
input-availablePulsing placeholder + “Generating video:
output-availableInline video player with controls, autoplay, loop, and mute
failedError message with suggestion to try a different prompt

Configuration

Video Model

chat.config.ts
models: {
  defaults: {
    video: "xai/grok-imagine-video",
  },
}

Model Selection Logic

When the tool runs, it resolves the model to use:
  1. If the user’s selected chat model supports video output (per the app model registry, model.output.video), use it.
  2. Otherwise, fall back to config.models.defaults.video.

Google Model Handling

For Google (Gemini) models, aspectRatio is passed in provider-specific options rather than as a top-level parameter.