Grok Imagine API: How to Use 50:11 Aspect Ratio in xAI Docs

Written by

in

Controlling Framing in xAI’s Grok Imagine Image Generation API

When generating images through xAI’s Grok image models (grok-imagine-image-2.0) on /v1/images/generations, the aspect_ratio parameter lets you set the output proportions directly rather than leaving framing to chance. When omitted, aspect_ratio defaults to auto, letting the model select a ratio suited to your prompt.

About 50:11: The official xAI image generation documentation (docs.x.ai) lists standard and wide ratios such as 1:1, 16:9 / 9:16, 4:3 / 3:4, 3:2 / 2:3, 2:1 / 1:2, 19.5:9 / 9:19.5, 20:9 / 9:20, 21:9, 5:2, and autoβ€”it does not list 50:11 as a documented preset. For ultra-wide panoramic banners or ribbon headers, 5:2 (2.5:1) or 21:9 (~2.33:1) are the closest documented wide options in xAI’s docs, or you can crop/pad a generated image to a custom 50:11 (~4.55:1) canvas in post-processing.


Supported Aspect Ratios in docs.x.ai

xAI’s image generation docs organize supported aspect_ratio values around common display, photography, and layout formats:

Aspect Ratio Typical Use Case
1:1 Social media, thumbnails
16:9 / 9:16 Widescreen, mobile, stories
4:3 / 3:4 Presentations, portraits
3:2 / 2:3 Photography
2:1 / 1:2 Banners, headers
19.5:9 / 9:19.5 Modern smartphone displays (iPhone)
20:9 / 9:20 Modern smartphone displays (Android)
21:9 Cinematic widescreen
5:2 Wide banners
auto Model auto-selects the best ratio for the prompt

Passing aspect_ratio Across SDKs and REST

You can pass aspect_ratio alongside model, prompt, resolution (1k default or 2k), quality (auto, low, or medium on grok-imagine-image-2.0), and response_format (url default or b64_json):

import xai_sdk

client = xai_sdk.Client()
response = client.image.sample(
    prompt="Panoramic harbor skyline at dusk, warm pier lights reflected on calm water",
    model="grok-imagine-image-2.0",
    aspect_ratio="5:2",
    resolution="2k",
)
print(response.url)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.XAI_API_KEY,
  baseURL: "https://api.x.ai/v1",
});

const response = await client.images.generate({
  model: "grok-imagine-image-2.0",
  prompt: "Panoramic harbor skyline at dusk, warm pier lights reflected on calm water",
  aspect_ratio: "5:2",
});

console.log(response.data[0].url);

Practical Tips for Extreme or Custom Ratios

  • Match composition to the ratio: Wide ratios (21:9, 5:2) reward horizontal staging and clear focal points; if your target slot is narrower or ultra-panoramic like 50:11, generate at 5:2 or 21:9 with extra breathing room around the subject before cropping or compositing.
  • Pair with resolution="2k" for cropping: Choosing 2k gives you more pixel headroom when trimming or fitting an image into a wide layout slot.
  • Persist URLs promptly: Default url responses return temporary hosted links, so use response_format="b64_json" or download the asset immediately if you plan to post-process or store it.

Comments

Leave a Reply

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