Generating Images with xAI’s Grok Imagine Image API
xAI’s image generation endpoint (/v1/images/generations) lets developers create images from text prompts with the Grok Imagine family—including grok-imagine-image and grok-imagine-image-2.0—while controlling framing via aspect_ratio and payload delivery via response_format (url vs. b64_json).
Rather than treating image generation as a black-box prompt call, production pipelines rely on three practical levers documented in the xAI API guides: explicit framing (aspect_ratio), deterministic output delivery (b64_json), and tuning quality/resolution alongside batch size.
Core Request Parameters
| Parameter | Purpose & Behavior | Practical Notes |
|---|---|---|
model |
Selects the Grok Imagine image model (such as grok-imagine-image-2.0). |
Pass the target model ID on every generation or edit request. |
prompt |
Natural-language description of the scene, subject, lighting, and composition. | Front-load concrete subjects, counts, and camera angle before styling. |
aspect_ratio |
Sets output proportions (such as 16:9 or 3:2), or defaults to auto. |
When omitted, auto lets the model pick the ratio suited to the prompt. |
response_format |
Controls return payload: url (default) or b64_json. |
Hosted URLs are temporary; use b64_json when storing or embedding directly. |
resolution & quality |
Sets output resolution (
Comments |
Leave a Reply