Images

Grok Imagine Image

xAI’s Grok Imagine Image 2.0: new images at 1K or 2K in eight shapes, and edits that combine up to 3 images.

Price

1K $0.045, 2K $0.06 an image, made at xAI’s medium quality. An edit costs the same as a new image; the images you send are included.

Make an image

import os
from openai import OpenAI
client = OpenAI(base_url="https://api.zurelay.com/v1", api_key=os.environ["ZURELAY_API_KEY"])
result = client.images.generate(
model="grok-imagine-image-2.0",
prompt="A poster for a mountain trail race: a runner on a ridge at sunrise, the words 'SUMMIT 50K' in bold condensed letters across the top",
size="2K",
extra_body={
"aspect_ratio": "2:3"
},
)
print(result.data[0].url)

Parameters

sizestring
1K (the default) or 2K.
aspect_ratiostring
1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9 or 21:9. Without it a new image is square; an edit keeps the shape of the image you send.
imagesarray
Up to 3 images to edit or combine, as links or data URLs (or files on /v1/images/edits).
ninteger
1 to 4 images.

Sizes are xAI’s own: about one megapixel at 1K (1024 × 1024 square, 1280 × 720 for 16:9) and about four at 2K. An image in another shape or resolution is retried, never delivered.

Edit and combine

import os
import requests
response = requests.post(
"https://api.zurelay.com/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['ZURELAY_API_KEY']}"},
json={
"model": "grok-imagine-image-2.0",
"prompt": "Put the woman from the first image in front of the bakery from the third, holding the bottle from the second.",
"images": [
"https://example.com/woman.jpg",
"https://example.com/bottle.jpg",
"https://example.com/bakery.jpg"
]
},
)
response.raise_for_status()
print(response.json())

Prompting

  • Describe the subject, the setting, the light and the medium in full sentences.
  • Put words that must appear in quotes and say where they go.
  • For edits, name what changes and what stays: “Change the sweater to deep blue. Keep everything else the same.”

Good to know

  • Images take 15 to 75 seconds.
  • There’s no quality setting: every image is made at medium quality, the level priced above.
  • Prompts the model declines return image_not_generated, free of charge.
  • Links last 24 hours; the Library in your dashboard keeps images returned as links for 30 days.

Model details and examples: Grok Imagine Image 2.0. More on sending images: Image editing and reference images.

Questions, or something missing? Ask our support team and we’ll answer by email, usually within a minute.