Framing Wide Banners with grok-imagine-image and aspect_ratio: "2:1"
xAI’s image generation API lets you specify proportional framing directly through the aspect_ratio parameter rather than hardcoding pixel dimensions. Setting aspect_ratio to "2:1" with a Grok image model such as grok-imagine-image-2.0 produces a wide 2-to-1 horizontal canvas tailored for web banners, article headers, and wide hero layouts.
Why 2:1 Works for Banners and Headers
A 2:1 aspect ratio gives you double the width of its height, creating horizontal breathing room without stretching into ultra-panoramic ratios like 21:9 or 5:2. According to the xAI image generation documentation:
- Primary fit: Banners and headers (
2:1), paired with vertical1:2when you need a tall counterpart. - Alternative framing: If you omit
aspect_ratio, it defaults toauto, allowing the model to choose a ratio based on the prompt. Other supported options include1:1,16:9/9:16,4:3/3:4,3:2/2:3,19.5:9/9:19.5,20:9/9:20,21:9, and5:2. - Decoupled scale and quality: Shape (
aspect_ratio) is separate from pixel scale (resolution, such as1kor2k) andquality(low,medium, orautoongrok-imagine-image-2.0), while batch size is controlled withn(1–10).
Calling /v1/images/generations with 2:1
Whether you use the xAI Python SDK, an OpenAI-compatible client pointed at [https://api.x.ai/v1](https://api.x.ai/v1), or the Vercel AI SDK, you pass the model name, prompt, and 2:1 ratio to generate images.
import xai_sdk
client = xai_sdk.Client()
response = client.image.sample(
prompt="Minimalist architectural studio overlooking coastal cliffs at dawn",
model="grok-imagine-image-2.0",
aspect_ratio="2:1",
)
print(response.url)
For batch generations or heavier workloads on /v1/images/generations, you can request multiple images via n (up to 10), choose url (the default for response_format) or base64, or use deferred: true for long-running batches and poll GET /v1/images/{request_id} or subscribe to image generation webhook events.
Practical Tips for 2:1 Prompts
- Compose horizontally: Describe wide foreground-to-background depth, split scenes, or left-to-right movement so the
2:1frame feels intentional rather than cropped. - Leave negative space if needed: If text or UI overlays will sit on top of a banner or header, ask for clean sky, wall, or background space on one side.
- Explore fast, then refine: Use
nto preview several2:1compositions in one call before locking in your preferred direction.
Leave a Reply