xAI Video Tool

Generate videos using xAI’s Grok video generation. Supports text-to-video, image-to-video (animate still images), and video editing.

Features

  • Text-to-video — Generate videos from text prompts
  • Image-to-video — Animate still images into videos
  • Video editing — Modify existing videos with prompts
  • Multiple aspect ratios — 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3
  • HD resolution — Up to 720p
  • Configurable duration — 1-15 seconds
  • Automatic delivery — Videos saved and delivered via Telegram/channels

Configuration

{
  "tools": {
    "xaiVideo": {
      "enabled": true,
      "apiKey": "YOUR_XAI_API_KEY",
      "model": "grok-imagine-video",
      "resolution": "480p",
      "duration": 5,
      "saveToMedia": true,
      "pollInterval": 5,
      "timeout": 600
    }
  }
}
FieldTypeDefaultDescription
enabledboolfalseEnable the tool
apiKeystring-xAI API key
modelstringgrok-imagine-videoVideo generation model
resolutionstring480pDefault resolution (480p or 720p)
durationint5Default video duration in seconds (1-15)
saveToMediabooltrueSave videos to media store for delivery
pollIntervalint5Seconds between status polls
timeoutint600Maximum wait time in seconds (10 minutes)

Usage

Basic Generation

{
  "prompt": "A cat walking across a sunny room"
}

With Parameters

{
  "prompt": "Ocean waves crashing on a beach at sunset",
  "duration": 10,
  "aspectRatio": "16:9",
  "resolution": "720p"
}

Image-to-Video

Animate a still image:

{
  "prompt": "Make the person wave and smile",
  "imageUrl": "https://example.com/photo.jpg"
}

The imageUrl must be a publicly accessible URL.

Video Editing

Modify an existing video:

{
  "prompt": "Add a hat to the person",
  "videoUrl": "https://example.com/video.mp4"
}

Video editing ignores duration and resolution parameters — output matches the input video.

Parameters

ParameterTypeRequiredDescription
promptstringYesVideo description with motion and action
durationintNoLength in seconds (1-15)
aspectRatiostringNo1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3
resolutionstringNo480p or 720p
imageUrlstringNoURL for image-to-video
videoUrlstringNoURL for video editing (max 8.7s input)

Aspect Ratios

RatioUse Case
1:1Square — social posts, thumbnails
16:9Landscape — YouTube, presentations
9:16Portrait — TikTok, Stories, Reels
4:3Classic — presentations
3:4Portrait classic
3:2Photo landscape
2:3Photo portrait

Response

Returns generated video path:

{
  "video": "./media/generated/video/abc123.mp4",
  "duration": 5,
  "prompt": "A cat walking across a sunny room"
}

If saving fails, returns URL instead:

{
  "url": "https://vidgen.x.ai/.../video.mp4",
  "duration": 5,
  "prompt": "A cat walking across a sunny room"
}

Examples

“Create a 5 second video of a rocket launching”

Agent calls xai_video, waits for generation (1-5 minutes), video is delivered to your Telegram.

“Animate this image of a landscape” (with attached image)

{
  "prompt": "Add gentle movement to the clouds and trees swaying in the wind",
  "imageUrl": "https://uploaded-image-url.jpg"
}

“Make this video look like it’s raining”

{
  "prompt": "Add rain effects with water droplets",
  "videoUrl": "https://uploaded-video-url.mp4"
}

Processing Time

Video generation is asynchronous and typically takes 1-5 minutes depending on:

  • Duration — Longer videos take more time
  • Resolution — 720p takes longer than 480p
  • Prompt complexity — Detailed scenes need more processing
  • Video editing — Editing existing videos adds overhead

The tool polls for status every 5 seconds (configurable) and times out after 10 minutes by default.

Limitations

  • Maximum 15 seconds for generation
  • Maximum 8.7 seconds input for video editing
  • Video editing doesn’t support custom duration/resolution
  • Subject to xAI content policies
  • Video URLs are temporary (saved to media store by default)

Troubleshooting

“API key required”

Set apiKey in the tool config.

Timeout Errors

Increase timeout in config. Complex videos may take longer than 10 minutes.

Videos Not Delivered

Check that saveToMedia is true (default) and your channel supports video.

Generation Failed/Expired

The request may have been rejected by content moderation or timed out on xAI’s side. Try a different prompt or shorter duration.


See Also