Skip to main content
POST

Authorizations

Authorization
string
header
required

All APIs require Bearer Token authentication

Add to request header:

Authorization: Bearer YOUR_API_KEY

Body

application/json
model
string
default:grok-imagine-image
required

grok-imagine-image: Supports text-to-image and image editing

Example:

"grok-imagine-image"

prompt
string
required

Image generation prompt

Notes:

  • Text-to-image mode: Describe the image content you want to generate
  • Image editing mode: Describe the editing requirements for the input image
Example:

"Abstract human silhouette, golden particles ready to burst outward representing joy"

num_outputs
integer
default:1

Number of output images

Notes:

  • Range: 1 - 4
  • Each image is billed independently
Example:

1

aspect_ratio
string | null

Output image aspect ratio

Options:

  • 2:1, 20:9, 19.5:9, 16:9, 4:3, 3:2, 1:1
  • 2:3, 3:4, 9:16, 9:19.5, 9:20, 1:2

Notes:

  • Only supported in text-to-image mode
  • Defaults to 1:1 upstream when not specified
Example:

"1:1"

output_format
string | null

Output image format

Options:

  • jpg / jpeg
  • png
  • webp

Notes:

  • Defaults to jpeg upstream when not specified

Do not pass this parameter unless necessary.

Example:

"jpg"

image_urls
string[] | null

List of input image URLs

Notes:

  • Automatically switches to image editing mode when provided
  • Supports up to 3 input images
  • Public accessible image URLs are recommended
Example:

Response

Task created successfully

created
integer

Task creation timestamp

Example:

1757165031

id
string

Task ID

Example:

"task-unified-1757165031-uyujaw3d"

model
string

Actual model name used

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:
image
Example:

"image"