Grok Imagine Image 2.0
A precise xAI image model: images from text, edits and composition from 1–5 images, mask edits. Strong at text and layout, including Cyrillic. 1K or 2K, 13 aspect ratios, one price per image plus a charge per input image.
Specifications
Capabilities
Description
What it does
- Image from text: the model follows instructions closely and sets text well: headlines, small print, poster and card layouts, including Cyrillic. Put the text for the image in quotes.
- Edits: describe what to change and the model keeps the rest. Composition from 2–5 images: refer to them as <IMAGE_0>, <IMAGE_1> and so on, in order.
- Mask edits (mask): an image of the same size; white areas are edited, black areas stay.
- Aspect ratio (aspect_ratio): 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1 or auto (default: text to image picks a ratio for the prompt, edits keep the first image's ratio). You can pass size, for example 1024x1024, and the gateway picks the ratio and resolution.
- Resolution (resolution): 1k (default, JPEG) or 2k (PNG, about 4 megapixels).
- Quality (quality): low is fast (6–17 seconds), medium adds detail (about a minute), auto lets the model choose (low for text to image, medium for edits). The price does not depend on quality or resolution.
- Input images: JPEG, PNG or WebP, each up to 20 MB, all together up to 32 MB; as files, data URIs or https links.
- One image per request. The model has no seed, negative prompt or file format choice.
How to call
Image from text: POST /v1/images/generations with a JSON body:
{"model": "xai/grok-imagine-image-2.0-08130", "prompt": "A coffee shop poster, large headline: \"COFFEE TO GO\"", "aspect_ratio": "2:3", "quality": "medium"}Edits and composition: POST /v1/images/edits as multipart; repeat the image field for each image (up to 5), the mask goes in the mask field:
curl https://api.neuralbridge.ru/v1/images/edits -H "Authorization: Bearer $API_KEY" -F model=xai/grok-imagine-image-2.0-08130 -F image=@photo.jpg -F mask=@mask.png -F "prompt=Replace the masked area with a starry night sky"Or /v1/images/generations with an images field: https links or data:image/png;base64,…. Send an Idempotency-Key header: repeating a request with the same key within a day returns the image already paid for.
Response
data[0].b64_json is the image in base64, output_format is jpeg (1k) or png (2k), usage holds width, height and the number of input images.
Errors
- 400: invalid input; the error text names the field (for example, an unsupported aspect ratio, more than 5 images or an http link). Rejected requests are not billed.
- 422 with code content_filtered: the image did not pass the model's content check. Nothing is charged.
- 402: not enough funds on the balance. 429: the model is overloaded. 502 or 504: the image was not received; nothing is charged.
Price
One price per finished image at any quality and resolution, plus a charge per input image (rates on this page). The mask is free.
Parameters
Endpoints
Code examples
Related models: image generation
/v1 in base_url. For Anthropic SDK — without /v1.