Video Generation
AI-powered video creation in your chat app
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:
ai: {
tools: {
video: {
enabled: true, // Requires durable file storage
},
},
}
Configure the default video model:
ai: {
tools: {
video: {
default: "xai/grok-imagine-video",
},
},
}
Parameters
The tool accepts the following inputs:
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
string | Required | Descriptive text for the video |
aspectRatio |
"16:9" | "9:16" | "1:1" |
"16:9" |
Output aspect ratio |
durationSeconds |
number (1–10) | 5 |
Length 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 through the configured Files SDK provider and the ChatJS file URL is returned. Supported container formats are mp4, webm, and mov, resolved from the response media type.
UI States
| State | Shows |
|---|---|
input-available |
Pulsing placeholder + Generating video: {prompt} |
output-available |
Inline video player with controls, autoplay, loop, and mute |
failed |
Error message with suggestion to try a different prompt |
Configuration
Video Model
ai: {
tools: {
video: {
default: "xai/grok-imagine-video",
},
},
}
Model Selection Logic
When the tool runs, it resolves the model to use:
- If the user’s selected chat model supports video output (per the app model registry,
model.output.video), use it. - Otherwise, fall back to
config.ai.tools.video.default.
Google Model Handling
For Google (Gemini) models, aspectRatio is passed in provider-specific options rather than as a top-level parameter.