Grok Imagine Image API: Aspect Ratio & Quality Guide

Written by

in

Framing and Fidelity in xAI’s Image Generation API

When building with xAI’s /v1/images/generations and /v1/images/edits endpoints, two knobs govern how your visuals behave in production: aspect_ratio (which locks canvas proportions before rendering) and quality (which controls generation fidelity and billing tier on grok-imagine-image-2.0).

If you have been referencing grok-imagine-image-quality from older documentation or code, note a major change: effective November 2, 2026, the grok-imagine-image-quality model slug was retired from the xAI API. Requests sent to grok-imagine-image-quality now automatically redirect to grok-imagine-image-2.0 with quality: "low".


What Happened to grok-imagine-image-quality?

Rather than keeping a separate grok-imagine-image-quality model slug, xAI consolidated image generation and editing under grok-imagine-image-2.0 and introduced an explicit quality parameter.

  • Automatic redirect: Calls to grok-imagine-image-quality (and legacy grok-imagine-image-pro redirects) are served by grok-imagine-image-2.0 pinned to quality: "low".
  • Lower cost at low quality: Serving grok-imagine-image-2.0 at quality: "low" is $0.01 per image cheaper than grok-imagine-image-quality across resolutions—priced at $0.04 per 1K image and $0.06 per 2K image (plus $0.01 per input image on edits).
  • Expanded capabilities: Migrating your model field to "grok-imagine-image-2.0" gives you explicit quality control (low, medium, auto), support for up to five source images on edits, and ultra-wide ratios like 21:9 and 5:2.

Controlling quality on grok-imagine-image-2.0

The quality parameter is supported specifically on grok-imagine-image-2.0 and accepts three values:

quality Value Behavior Best Use Case
low Lower cost and faster iteration; used by default when auto is selected for fresh image generations. Rapid prompt exploration, wireframes, and multi-image batches (n up to 10).
medium Higher detail and fidelity; used by default when auto is selected for image edits. Final selects, precision edits, and scenes with intricate textures or subjects.
auto Default when omitted; currently resolves to low for /v1/images/generations and medium for /v1/images/edits. General workflows where you want automatic defaults without pinning a tier.

Because billing follows the quality level at which an image is served, explicitly passing "low" or "medium" in production prevents surprises if auto behavior ever shifts. You can also pair quality with resolution ("1k" by default, or "2k") to balance sharpness against cost.


Designing Layouts with aspect_ratio

Passing aspect_ratio tells the model the exact target proportions of the output canvas. Omitting it defaults to "auto", letting the model infer the ratio from your prompt—handy for one-off ideation, but risky when UI slots or multi-image grids demand uniform dimensions.

Supported ratios span standard photography, widescreen, banners, and modern tall phone displays:

  • Square & classic photo: 1:1 (social squares, thumbnails), 4:3 / 3:4 (presentations, portraits), and 3:2 / 2:3 (traditional photography).
  • Video & mobile screens: 16:9 / 9:16 (widescreen and vertical video/stories), plus tall handset ratios like 19.5:9 / 9:19.5 and 20:9 / 9:20 so wallpapers and full-bleed mobile backgrounds avoid awkward cropping.
  • Wide & panoramic canvases: 2:1 / 1:2 (banners and headers), 21:9 (cinematic widescreen), and 5:2 (extra-wide banners).

Practical Tip for Series and Edits

When generating a cohesive visual series, lock aspect_ratio across every call and keep your prompt structure consistent (subject, focal details, art direction, lighting, color, and composition) so frames sit naturally side by side. For targeted edits on an existing image, either match the source ratio or let framing stay aligned so you do not inadvertently clip key subjects.


Example API Request

Here is a direct REST call to /v1/images/generations using grok-imagine-image-2.0 with explicit aspect_ratio and quality settings:

curl -X POST https://api.x.ai/v1/images/generations 
  -H "Authorization: Bearer $XAI_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "model": "grok-imagine-image-2.0",
    "prompt": "Architectural photograph of a minimalist concrete pavilion beside a calm mountain lake at dawn, warm low-angle sunlight, clean lines, sharp focus",
    "aspect_ratio": "16:9",
    "resolution": "2k",
    "quality": "medium",
    "n": 1
  }'

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *