generate_video
Create videos from text prompts, images, or reference images, with customizable duration, resolution, and aspect ratio. Delivers MP4 files with auto-generated audio.
Instructions
Generate a new video using xAI Grok Imagine Video API (grok-imagine-video). Supports text-to-video (T2V), image-to-video (I2V), and reference-to-video (R2V). Supports aspect ratios: 16:9, 4:3, 1:1, 9:16, 3:4, 3:2, 2:3. Video duration: 1-15 seconds (default 8). Resolution: 480p, 720p, or 1080p (1080p only with model grok-imagine-video-1.5). The output MP4 always contains an auto-generated audio track (sound effects, ambience, score) driven by the prompt; there is no audio parameter. For image-to-video, provide image_url, image_path, or image_file_id. For reference-to-video, provide reference_images.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Model to use (default: grok-imagine-video) | |
| prompt | No | Text prompt describing the video. Required for text-to-video and reference-to-video; optional for image-to-video (image alone drives generation). | |
| duration | No | Video duration in seconds (1-15, default: 8) | |
| image_url | No | Source image URL for image-to-video generation (optional) | |
| image_path | No | Local image file path for image-to-video generation. Sent as a base64 data URL; files over 10 MB are uploaded via the xAI Files API automatically (max 48 MB). Cannot be used together with image_url or image_file_id. | |
| resolution | No | Resolution of the generated video (default: 720p). 1080p is only available with model grok-imagine-video-1.5 (text-to-video and image-to-video). | |
| output_path | No | Output file path (default: generated_video.mp4) | |
| aspect_ratio | No | Aspect ratio (default: 16:9) | |
| image_file_id | No | File ID from the xAI Files API for image-to-video generation. Cannot be used together with image_url or image_path. | |
| reference_images | No | Reference images for reference-to-video (R2V) generation, used as style/content references. Cannot be combined with image_url/image_path/image_file_id. Requires model grok-imagine-video; grok-imagine-video-1.5 rejects R2V. |