generate_image
Create new images or edit existing ones with Grok Imagine using a text prompt plus optional image files or URLs as references.
Instructions
Generate new images or edit existing ones with Grok Imagine.
Pass `image_paths` and/or `image_urls` to edit images or use them as
visual references. Multiple references are combined in a single call.
Args:
prompt: Image description, or the edit instruction when references are provided.
model: Image model (`grok-imagine-image` or `grok-imagine-image-pro`).
image_paths: Local image files (JPG/PNG) used as edit sources or references.
image_urls: Public image URLs used as edit sources or references.
n: Number of images to generate (1–10).
image_format: `"url"` (default) or `"base64"`. Base64 responses carry no URL,
so they are always saved locally.
aspect_ratio: Aspect ratio like `"16:9"`, `"1:1"`, or `"9:16"`.
resolution: `"1k"` or `"2k"`.
save: Write each image to `images/` and report the local path instead of the
remote URL. Remote URLs are temporary, so save anything you want to keep.
show_usage: Append a token usage and cost footer to the result (default False).
Returns:
Markdown block listing each image as a saved local path when saving, otherwise
as a temporary remote URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | ||
| save | No | ||
| model | No | grok-imagine-image | |
| prompt | Yes | ||
| image_urls | No | ||
| resolution | No | ||
| show_usage | No | ||
| image_paths | No | ||
| aspect_ratio | No | ||
| image_format | No | url |