Skip to main content
POST

Authorizations

Authorization
string
header
required

API Key authentication. Format: Bearer YOUR_API_KEY.

Body

application/json

xAI Grok Imagine image editing request. Shared by the Quality and standard edit models. A single image is passed as a one-element images array.

prompt
string
required

Text description of the edit to apply

Minimum string length: 1
Example:

"Render this as a pencil sketch with detailed shading"

images
string[]
required

Source images to edit (1-3). Each item is a publicly accessible image URL or a base64 data URI.

Required array length: 1 - 3 elements
Minimum string length: 1
Example:
n
integer

Number of edited images to generate

Required range: x >= 1
Example:

1

aspect_ratio
enum<string>

Aspect ratio of the edited output 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: 1k (1024px) or 2k (2048px). Defaults to 1k.

Available options:
1k,
2k
Example:

"1k"

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.