Skip to main content
POST
Grok Imagine Image 2.0

Headers

Authorization
string

Body

application/json
model
enum<string>
required

Model name. Must be grok-image-2.

Available options:
grok-image-2
prompt
string

Text prompt. Required for text-to-image; optional in edit mode (omit it to let the model reinterpret the source image).

Required string length: 1 - 5000
ratio
enum<string>
default:auto

Aspect ratio. In edit mode (when image_list is provided) it defaults to auto, which keeps the source framing. In text-to-image mode auto is not supported and falls back to 1:1.

Available options:
auto,
1:1,
2:3,
3:2,
16:9,
9:16
custom_callback_url
string

Optional callback URL for task status updates.

image_list
object[]

Optional reference images, e.g. [{"url": "https://..."}]. Providing them switches the request to image-edit mode, billed at the same rate as text-to-image. Formats: .jpg / .jpeg / .png / .webp, up to 30MB each. Up to 5 (upstream hard limit).

Required array length: 1 - 5 elements

Response

code
integer
required
msg
string
required
data
object
required