Generating Promotional Images with Grok
On this page
Updated November 2, 2026 — Imagine. As of November 2, 2026,
grok-imagine-image-qualityis removed: its requests are served by Imagine Image 2.0 (grok-imagine-image-2.0, $0.04 per image) atlowquality. Replace the ID in examples and set the desired quality;grok-imagine-image(version 1.0) is unaffected. Imagine Image 2.0 accepts up to five reference images and theautoquality setting, which is now the default.
Images at the heart of your marketing strategy
Visual content consistently generates more engagement than text alone. But producing professional-quality visuals is expensive and time-consuming: briefing a designer, waiting for drafts, iterating. With grok-imagine-image, you generate marketing visuals in seconds, at a negligible cost.
This lesson shows you how to leverage Grok’s image generation for your marketing needs: campaign visuals, blog illustrations, banners, and social media assets.
Image generation models
Grok offers two image generation models:
- grok-imagine-image (Imagine 1.0): $0.02/image, 6 requests per second
- grok-imagine-image-2.0 (Imagine 2.0): $0.04/image at
lowquality,qualitysetting (low,medium,auto), 6 requests per second
For day-to-day marketing (social posts, blog illustrations, email banners), the standard model suffices. Reserve the quality model for major campaign visuals or assets intended for print.
Generating campaign visuals
Social media visuals
Each platform has its own dimensions. The aspect_ratio parameter lets you adapt the format:
from openai import OpenAI
client = OpenAI(
api_key="your-xai-key",
base_url="https://api.x.ai/v1"
)
# Visual for X or Instagram post (square)
response = client.images.generate(
model="grok-imagine-image",
prompt="""Clean marketing visual for a French tech brand.
Style: minimalist flat design, dark background, electric blue accents.
Subject: a chart showing an upward growth curve
with floating data icons. No text.""",
n=1,
extra_body={"aspect_ratio": "1:1", "resolution": "2k"},
)
# Banner for X (landscape)
response_banner = client.images.generate(
model="grok-imagine-image",
prompt="""Horizontal promotional banner. Modern corporate style.
Gradient from midnight blue to violet. Abstract geometric shapes
symbolizing connectivity. Empty space on the left for adding
text. No text in the image.""",
n=1,
extra_body={"aspect_ratio": "16:9", "resolution": "2k"},
)
Tip: Reserve space for text
When generating visuals where you’ll add text later (with a design tool), specify in the prompt to leave empty space. Grok generally respects these spatial instructions.
Producing batch variants
The n parameter lets you generate up to 10 variants in a single request. This is ideal for visual A/B testing:
response = client.images.generate(
model="grok-imagine-image",
prompt="""Illustration for a blog post on artificial
intelligence in business. Style: isometric, warm colors,
stylized characters interacting with holographic screens.""",
n=4,
extra_body={"aspect_ratio": "16:9", "resolution": "1k"},
)
# Retrieve the 4 variants
for i, image in enumerate(response.data):
print(f"Variant {i+1}: {image.url}")
Editing and refining existing images
The editing API lets you modify an existing or generated image. This is useful for:
- Adapting an image to a style guide
- Changing a detail without regenerating everything
- Creating variations of the same visual
Editing requires a different client: the xAI API expects a JSON request, while the OpenAI SDK’s images.edit() method sends multipart; xAI documentation therefore indicates using the xAI SDK (pip install xai-sdk) or a direct HTTP request.
import xai_sdk
xai_client = xai_sdk.Client() # reads key from XAI_API_KEY
# Edit an existing image
response = xai_client.image.sample(
model="grok-imagine-image",
prompt="Change the background to a navy blue to black gradient. Keep the main subject intact.",
image_url="https://your-cdn.com/original-visual.jpg",
)
print(response.url)
Chaining edits
You can iterate on a visual by using the output URL as the input for the next request. This lets you build a visual through successive steps:
# Step 1: Generate base visual
etape1 = client.images.generate(
model="grok-imagine-image",
prompt="Modern office scene with screens displaying data",
extra_body={"aspect_ratio": "16:9"},
)
# Step 2: Add an element (edit with xAI SDK)
etape2 = xai_client.image.sample(
model="grok-imagine-image",
prompt="Add ambient blue light coming from the screens",
image_url=etape1.data[0].url,
)
# Step 3: Finalize
etape3 = xai_client.image.sample(
model="grok-imagine-image",
prompt="Add a depth of field effect, blur on the background",
image_url=etape2.url,
)
Creating a marketing visual library
To maintain visual consistency across your campaigns, create a system of reusable prompts:
STYLES_MARQUE = {
"corporate": """Modern corporate style. Palette: navy blue (#1a237e),
white (#ffffff), light gray (#f5f5f5). Clean geometric shapes.
Soft, professional lighting.""",
"tech": """Futuristic tech style. Palette: deep black, electric blue,
neon violet. Circuit board lines, light particles.
Innovative atmosphere.""",
"humain": """Warm and human style. Palette: earth tones, soft orange,
beige. Illustrations of diverse people collaborating.
Inclusive and accessible ambiance."""
}
def generer_visuel_marque(sujet, style="corporate", ratio="16:9"):
prompt = f"{sujet}. {STYLES_MARQUE[style]} No text in the image."
response = client.images.generate(
model="grok-imagine-image",
prompt=prompt,
extra_body={"aspect_ratio": ratio, "resolution": "2k"},
)
return response.data[0].url
Limitations and best practices
What you need to know
- Generated URLs are temporary: download images to your CDN immediately
- Content moderation is applied automatically
- The model handles text in images poorly (lettering often approximate): add text with a design tool
- Generated images are not under copyright, but check xAI’s terms of use
Marketing best practices
- Always generate multiple variants to choose the best one
- Maintain a prompt guide consistent with your style guide
- Combine AI generation + manual editing for high-value visuals
- Use the quality model ($0.05) only for assets intended for premium use
Prices listed as of August 5, 2026 — prices change regularly: before any budget calculation, check the current rate card on the official xAI models and pricing page.
Key takeaways
grok-imagine-imagecosts $0.02/image, the quality model $0.05/image- Use
aspect_ratioto adapt visuals to each platform (1:1, 16:9, 9:16) - Generate up to 10 variants per request with the
nparameter - Chain edits to build a visual through successive iterations
- Create reusable prompts aligned with your style guide
- Download images immediately: URLs are temporary