xAI API Image Generation: Aspect Ratio & Quality Guide

Written by

in

xAI retired the grok-imagine-image-quality model slug on November 2, 2026, consolidating image generation and editing under grok-imagine-image-2.0 with explicit quality, aspect_ratio, and resolution controls on /v1/images/generations and /v1/images/edits. Existing requests to grok-imagine-image-quality (and legacy redirects from grok-imagine-image-pro) are automatically routed to grok-imagine-image-2.0 at quality: "low", reducing cost by $0.01 per image compared to the retired slug’s pricing.


What Changed With grok-imagine-image-quality

Following a 60-day notice period that started September 2, 2026, grok-imagine-image-quality became a migration path rather than a standalone target model on November 2, 2026.

  • Automatic routing: Calls to grok-imagine-image-quality on /v1/images/generations or /v1/images/edits execute on grok-imagine-image-2.0 with quality: "low".
  • Lower per-image cost: Running grok-imagine-image-2.0 at low quality costs $0.01 less per image than grok-imagine-image-quality at every supported resolution.
  • Verification: You can confirm active routing by checking usage.cost_in_usd_ticks in API responses or inspecting model reporting (such as grok-imagine-image-2.0-low in gRPC SDK responses).
  • Migration: Update your model parameter from grok-imagine-image-quality to grok-imagine-image-2.0, and explicitly pass quality when you want predictable behavior rather than relying on redirect defaults.

Controlling aspect_ratio and quality in Image Generations

When generating images via /v1/images/generations or the xAI SDKs on grok-imagine-image-2.0, you can control framing, quality tier, resolution, batch count, and output format.

aspect_ratio

  • Default (auto): Omitting aspect_ratio (or setting auto) lets the model select dimensions suited to the prompt.
  • Supported ratios: Common ratios include 16:9 and 9:16 (widescreen, mobile, stories) and 4:3 and 3:4 (presentations, portraits), alongside wider ratios such as 21:9 and 5:2 available on grok-imagine-image-2.0.

quality and resolution

  • Allowed quality values: low, medium, and auto (supported on grok-imagine-image-2.0).
  • How auto behaves: When quality is omitted or set to auto, the service chooses dynamically—currently defaulting to low for image generation and medium for image editing.
  • Resolutions: Supported presets are 1k (default) and 2k. According to xAI’s prompting guidance, pinning medium quality and 2k resolution is best when fine details must stay clearly recognizable, while low quality and 1k resolution suit fast iteration and drafts.
  • Billing alignment: Images are billed according to the quality and resolution served, so pinning low or medium avoids surprises if auto changes or if you want explicit cost control.

Practical Request Parameters and Patterns

Parameter / Option Behavior on /v1/images/generations Notes
model Target model ID (grok-imagine-image-2.0) Replace grok-imagine-image-quality directly
aspect_ratio Controls output framing (auto default, plus ratios like 16:9, 9:16, 4:3, 3:4, 21:9, 5:2) Pick explicit ratios for fixed UI or layout slots
quality low, medium, or auto (grok-imagine-image-2.0 only) auto uses low for generation and medium for edits
resolution 1k (default) or 2k Higher resolution paired with medium quality preserves fine detail
n Batch count from 1 to 10 (defaults to 1 on REST/OpenAI-compatible) Python SDK uses sample() for 1 image and sample_batch(n=...) for batches
response_format url (default temporary URL) or base64 for direct embedding Deferred requests support url only and retain results for 24 hours

For long-running batches or decoupled pipelines, you can set deferred: true to receive a request_id and poll GET /v1/images/{request_id}, or configure webhooks for image.generation.completed and image.generation.failed events. When generating distinct prompts concurrently, using an async client with parallel task execution is faster than sequential requests.

Comments

Leave a Reply

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