xAI Imagine Tool

Generate images using xAI’s Grok image generation. Supports text-to-image and image-to-image transformation.

Features

  • Text-to-image — Generate images from text prompts
  • Image-to-image — Transform existing images with prompts
  • Multiple aspect ratios — 1:1, 16:9, 9:16, 4:3, 3:4
  • High resolution — Up to 2K (~2048px)
  • Batch generation — Up to 4 images per request
  • Automatic delivery — Images saved and delivered via Telegram/channels

Configuration

{
  "tools": {
    "xaiImagine": {
      "enabled": true,
      "apiKey": "YOUR_XAI_API_KEY",
      "model": "grok-2-image",
      "resolution": "1K",
      "saveToMedia": true
    }
  }
}
FieldTypeDefaultDescription
enabledboolfalseEnable the tool
apiKeystring-xAI API key (can share with provider)
modelstringgrok-2-imageImage generation model
resolutionstring1KDefault resolution (1K or 2K)
saveToMediabooltrueSave images to media store for delivery

Usage

Basic Generation

{
  "prompt": "A futuristic city at sunset with flying cars"
}

With Parameters

{
  "prompt": "A serene mountain landscape",
  "aspectRatio": "16:9",
  "resolution": "2K",
  "count": 2
}

Image-to-Image

Transform an existing image:

{
  "prompt": "Make this image look like a watercolor painting",
  "inputImage": "https://example.com/photo.jpg"
}

The inputImage must be a publicly accessible URL.

Parameters

ParameterTypeRequiredDescription
promptstringYesImage description
modelstringNoModel override
aspectRatiostringNo1:1, 16:9, 9:16, 4:3, 3:4
resolutionstringNo1K (~1024px) or 2K (~2048px)
countintNoNumber of images (1-4)
saveToMediaboolNoSave to media store
inputImagestringNoURL for image-to-image

Aspect Ratios

RatioUse Case
1:1Square — avatars, icons, social posts
16:9Landscape — desktop wallpapers, presentations
9:16Portrait — phone wallpapers, stories
4:3Classic — photos, documents
3:4Portrait classic — print photos

Response

Returns generated image URLs:

{
  "images": [
    {
      "url": "https://...",
      "revisedPrompt": "A detailed futuristic cityscape..."
    }
  ]
}

The revisedPrompt shows how xAI interpreted your prompt.

Examples

“Draw a cute robot reading a book”

Agent calls xai_imagine, image is generated and delivered to your Telegram.

“Generate a 16:9 banner image for my blog post about AI”

{
  "prompt": "Minimalist banner illustration of neural network patterns, blue gradient, modern tech aesthetic",
  "aspectRatio": "16:9",
  "resolution": "2K"
}

“Turn this photo into pixel art” (with attached image)

{
  "prompt": "Convert to 16-bit pixel art style, retro gaming aesthetic",
  "inputImage": "https://uploaded-image-url.jpg"
}

Limitations

  • Subject to xAI content policies
  • Image URLs are temporary (saved to media store by default)
  • Maximum 4 images per request
  • Image-to-image requires publicly accessible source URL

Troubleshooting

No Images Delivered

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

“API key required”

Set apiKey in the tool config or share from the xAI provider.

Low Quality Results

  • Be more descriptive in prompts
  • Use 2K resolution for higher quality
  • Specify style explicitly (e.g., “photorealistic”, “digital art”, “oil painting”)

See Also