Skip to main content
POST

Authorizations

Authorization
string
header
required

API Key authentication. Format: Bearer YOUR_API_KEY.

Body

application/json

xAI Grok Imagine text-to-image request. Shared by the Quality and standard image generation models.

prompt
string
required

Text description of the image to generate

Minimum string length: 1
Example:

"A collage of London landmarks in a stenciled street-art style"

n
integer

Number of images to generate (official examples use 4; no fixed upper limit)

Required range: x >= 1
Example:

1

aspect_ratio
enum<string>

Aspect ratio of the generated image

Available options:
1:1,
16:9,
9:16,
4:3,
3:4,
3:2,
2:3,
2:1,
1:2,
19.5:9,
9:19.5,
20:9,
9:20,
auto
Example:

"16:9"

resolution
enum<string>
default:1k

Output resolution tier

Available options:
1k,
2k
Example:

"2k"

response_format
enum<string>

Format of the returned image data

Available options:
url,
b64_json
Example:

"url"

Response

Task submitted successfully

code
integer
required

Response code, 0 indicates success

Example:

0

message
string
required

Response message

Example:

"success"

data
object
required

Detailed data about the submitted asynchronous task.