NeuralBridge
Sign in Download IDE
xAI

Grok Imagine Image 2.0

image generation

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

Context window
—
Max tokens in response
—
Vendor
xAI
Release
—
Login
text, images
Output
images

Capabilities

generationeditingmulti_ref

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

size
Result size as a "width×height" string.
width
Image width in pixels.
height
Image height in pixels.
prompt
The request text: what you want to get. For video: the scene, camera movement and light; for music: genre, mood, instruments, tempo. The length limit depends on the model.
images
1 to 16 PNG, JPEG or WEBP images: edits, style transfer, building a scene from objects. Up to 25 MB each, 50 MB in total.
reference_images
How many reference images can be passed.
reference_image_mb
Megabytes per image.
reference_images_total_mb
reference_image_formatsimage/jpeg · image/png · image/webp
aspect_ratiodefault: auto · auto · 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
Aspect ratio of the result, for example 16:9, 9:16 or 1:1.
qualitydefault: auto · auto · low · medium
Generation quality: faster and cheaper versus slower and more detailed.
resolutiondefault: 1k · 1k · 2k
Video resolution, for example 720P or 1080P. Also affects the price.
mask
An image the size of the edited one: white areas are edited, black areas stay as they are.

Endpoints

POSThttps://api.neuralbridge.ru/v1/images/generationsprimary
Images — generations — Generate an image from a text description.

Code examples

python
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.neuralbridge.ru/v1")

image = client.images.generate(model="xai/grok-imagine-image-2.0-08130", prompt="Рыжий кот в скафандре")

print(image.data[0].url or image.data[0].b64_json[:64])
For OpenAI SDK, specify /v1 in base_url. For Anthropic SDK — without /v1.
Prices
Image / image6,30 ₽
Input image / image1,575 ₽
The request cost in rubles — in the response, field usage.cost
Identifier
xai/grok-imagine-image-2.0-08130
Get API key