Skip to main content
POST

Authorizations

Authorization
string
header
required

##All APIs require Bearer Token authentication##

Get API Key:

Visit API Key Management Page to get your API Key

Add to request header:

Body

application/json
model
enum<string>
required

Image generation model name. Text-to-image and image editing share this model name; the mode switches automatically depending on whether image_urls is provided

Available options:
grok-imagine-image-2.0
Example:

"grok-imagine-image-2.0"

prompt
string
required

Prompt describing the image you want to generate, or how to edit the reference images you provide

Multi-image reference syntax:

  • When passing multiple reference images, use <IMAGE_0>, <IMAGE_1>, <IMAGE_2> in the prompt to refer to the 1st, 2nd and 3rd reference image respectively
  • Indexes start at 0 and map one-to-one to the order of the image_urls array
  • Example: Place the person from <IMAGE_0> into the scene of <IMAGE_1>
Example:

"Cyberpunk Tokyo street at night, neon lights reflecting on the wet pavement"

image_urls
string<uri>[]

Reference image URL list for image-to-image and image editing functions

Note:

  • Number of input images per request: 0~3 (omitted = text-to-image, 1~3 = image editing)
  • Only publicly accessible http / https image URLs are supported; base64 and data URLs are not supported
  • Supported file formats: .jpeg, .jpg, .png, .webp
  • Image URLs must be directly accessible by the server, or the image URL should directly download when accessed (typically these URLs end with image file extensions, such as .png, .jpg)
  • In image editing scenarios the reference images incur an additional charge, counted once per request and not multiplied by n
Maximum array length: 3
Example:
size
enum<string>
default:auto

Aspect ratio of the generated image, defaults to auto

Supported ratios (13):

Note:

  • auto: the model decides the ratio itself; omitting this parameter is equivalent to auto (output is usually portrait)
  • Values outside the table above are not supported
Available options:
1:1,
4:3,
3:4,
3:2,
2:3,
16:9,
9:16,
2:1,
1:2,
19.5:9,
9:19.5,
20:9,
9:20,
auto
Example:

"16:9"

resolution
enum<string>
default:1K

Pixel tier of the output image, defaults to 1K; supports the 1K and 2K tiers

Note:

  • This model does not support 4K
  • Values are case-insensitive
Available options:
1K,
2K
Example:

"1K"

quality
enum<string>
default:medium

Generation quality tier, controls how deeply the model thinks, defaults to medium

Note:

  • This model only supports the low / medium tiers; other values such as high are not supported
  • quality (quality tier) and resolution (pixel tier) are independent and can be combined freely
  • Values are case-insensitive
Available options:
low,
medium
Example:

"medium"

n
integer
default:1

Number of images to generate, range 1~10, defaults to 1

Note:

  • Each image is billed independently, cost grows linearly with n
  • The additional charge for reference images is counted once per request and is not multiplied by n
  • When the task completes, result_urls returns n independent image links
Required range: 1 <= x <= 10
Example:

1

callback_url
string<uri>

HTTPS callback address after task completion

Callback Timing:

  • Triggered when task is completed, failed, or cancelled
  • Sent after billing confirmation is completed

Security Restrictions:

  • Only HTTPS protocol is supported
  • Callback to internal IP addresses is prohibited (127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, etc.)
  • URL length must not exceed 2048 characters

Callback Mechanism:

  • Timeout: 10 seconds
  • Maximum 3 retries on failure (retries after 1 second/2 seconds/4 seconds)
  • Callback response body format is consistent with the task query API response format
  • Callback address returning 2xx status code is considered successful, other status codes will trigger retry
Example:

"https://your-domain.com/webhooks/image-task-completed"

Response

Image generation task created successfully

created
integer

Task creation timestamp

Example:

1757156493

id
string

Task ID

Example:

"task-unified-1757156493-imcg5zqt"

model
string

Actual model name used

Example:

"grok-imagine-image-2.0"

object
enum<string>

Specific task type

Available options:
image.generation.task
progress
integer

Task progress percentage (0-100)

Required range: 0 <= x <= 100
Example:

0

status
enum<string>

Task status

Available options:
pending,
processing,
completed,
failed
Example:

"pending"

task_info
object

Asynchronous task information

type
enum<string>

Task output type

Available options:
text,
image,
audio,
video
Example:

"image"

usage
object

Usage and billing information