generate_image
Create or edit images using Grok Imagine. Provide a text prompt, specify model and parameters like count, aspect ratio, and resolution to generate images or modify existing ones.
Instructions
Generate new images or edit existing ones with Grok Imagine.
Args:
prompt: Image description or edit instruction.
model: Image model (grok-imagine-image or grok-imagine-image-pro).
image_paths: Local image files 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".
aspect_ratio: Aspect ratio like "16:9", "1:1", or "9:16".
resolution: "1k" or "2k".
Returns: MediaResult containing image metadata and URLs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | ||
| model | No | grok-imagine-image | |
| prompt | Yes | ||
| image_urls | No | ||
| resolution | No | ||
| image_paths | No | ||
| aspect_ratio | No | ||
| image_format | No | url |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | Human-formatted output (includes footers, citations, cost summary). | |
| model | Yes | Actual executing model ID (e.g. 'grok-4.5'). | |
| plane | No | API | |
| route | Yes | High-level route (fast/agentic/research/etc.). | |
| images | No | Grok Imagine image URLs. | |
| tokens | No | Total tokens consumed. | |
| profile | No | Internal routing profile. | |
| summary | No | Legacy/duplicate formatted summary of the media generation. | |
| cost_usd | No | Exact USD cost from xAI billing metadata. | |
| response | Yes | Raw model output or primary content. | |
| citations | No | Native xAI/X citations with URL + snippet. | |
| video_url | No | ||
| latency_sec | No | ||
| duration_sec | No | ||
| finish_reason | No | unknown | |
| imagine_params | No | Original prompt + seed for reproducibility. | |
| reasoning_effort | No | Grok 4.5+ native reasoning level. |