Skip to content
中文

Grok Imagine Image 2.0 API documentation

Integrate Grok Imagine Image 2.0 with your VezAPI key. The operations below share the same authentication and account balance.

Base URL: https://api.vezapi.com
Send Authorization: Bearer YOUR_VEZAPI_KEY. Use a unique Idempotency-Key for each submission; reuse it only when checking the same request.

Grok Imagine Image 2.0 Segment Edit

POST/api/v1/jobs/createTask

Model IDs: grok-imagine-image-2-0/segment-edit

ParameterTypeDescription & constraints
model
required
string

The model name used for generation. This field is required. This endpoint must use the `grok-imagine-image-2-0/segment-edit` model.

Values: "grok-imagine-image-2-0/segment-edit"

Default: "grok-imagine-image-2-0/segment-edit"

callBackUrl
optional
string

Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent.

input
required
object

Input parameters for the Grok Imagine image editing task.

input.prompt
required
string

Text prompt describing the desired image. Up to 65,000 characters.

maxLength: 65000

input.task_id
required
string

The source task ID to use for image editing(This can be a task ID generated by the `grok-imagine-image-2-0/text-to-image` model, or a task ID generated by the `grok-imagine-image-2-0/segment-map` model by passing an `image_url`.).

input.mask_indexs
optional
array

Indexes of the segments to edit, taken from resultObject.segments[].index of the segment-map task (0-based). Example: [0, 2].

minItems: 1

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "grok-imagine-image-2-0/segment-edit",
  "input": {
    "prompt": "Change the background to a sunset beach while preserving the subject.",
    "task_id": "task_grok_imagine_1234567890"
  }
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
optional
string

Response message, error description upon failure

data
required
object
data.taskId
required
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Grok Imagine Image 2.0 Image Edit

POST/api/v1/jobs/createTask

Model IDs: grok-imagine-image-2-0/image-edit

ParameterTypeDescription & constraints
model
required
string

The model name to use for generation. Required field. - Must be `grok-imagine-image-2-0/image-edit` for this endpoint

Values: "grok-imagine-image-2-0/image-edit"

Default: "grok-imagine-image-2-0/image-edit"

callBackUrl
optional
string

The URL to receive generation task completion updates. Optional but recommended for production use. - System will POST task status and results to this URL when generation completes - Callback includes generated content URLs and task information - Your callback endpoint should accept POST requests with JSON payload containing results - Alternatively, use the Get Task Details endpoint to poll task status - To ensure callback security, see [Webhook Verification Guide](/common-api/webhook-verification) for signature verification implementation

input
optional
object

Input parameters for the generation task

input.prompt
optional
string

A text description specifying the desired content or style of the generated image. Up to 8,000 characters.

maxLength: 8000

input.aspect_ratio
required
string

Specifies the width-to-height ratio of the generated image. Controls the aspect ratio of the output. This field is required.

Values: "1:1", "2:3", "3:2", "16:9", "9:16", "auto"

input.image_urls
required
array

An array containing up to 5 and at least 1 URL strings pointing to a reference image.

maxItems: 5

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "grok-imagine-image-2-0/image-edit",
  "input": {
    "prompt": "Recreate the Titanic movie poster with two adorable anthropomorphic cats in the same romantic pose at the bow of the ship. The male cat is an orange tabby wearing a vest, standing behind a white long-haired female cat in a lace dress, holding her paws as they stretch forward in the wind. Both cats are photorealistic with detailed fur, wind-swept hair, and dramatic sunset lighting (warm golden highlights, cool blue shadows). Background: the Titanic ship at dusk with four smokestacks, glowing deck lights, calm ocean, and orange-pink sunset sky. Center title: “CATANIC” in the same gold metallic serif style as Titanic, same size and position.",
    "aspect_ratio": "1:1",
    "image_urls": [
      "https://example.com/input.png"
    ]
  }
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
optional
string

Response message, error description upon failure

data
required
object
data.taskId
required
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Grok Imagine Image 2.0 Segment Map

POST/api/v1/jobs/createTask

Model IDs: grok-imagine-image-2-0/segment-map

ParameterTypeDescription & constraints
model
required
string

The model name used for generation. This field is required. This endpoint must use the `grok-imagine-image-2-0/segment-map` model.

Values: "grok-imagine-image-2-0/segment-map"

Default: "grok-imagine-image-2-0/segment-map"

callBackUrl
optional
string

Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent.

input
required
object

Input parameters for the segment map task.

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "grok-imagine-image-2-0/segment-map",
  "input": {
    "task_id": "task_grok_imagine_1765180586443"
  }
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
optional
string

Response message, error description upon failure

data
required
object
data.taskId
required
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Grok Imagine Image 2.0 Text To Image

POST/api/v1/jobs/createTask

Model IDs: grok-imagine-image-2-0/text-to-image

ParameterTypeDescription & constraints
model
required
string

The model name used for generation. This field is required. This endpoint must use the `grok-imagine-image-2-0/text-to-image` model.

Values: "grok-imagine-image-2-0/text-to-image"

Default: "grok-imagine-image-2-0/text-to-image"

callBackUrl
optional
string

Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent.

input
required
object

Input parameters for the image generation task.

input.prompt
required
string

Text prompt describing the desired image. This field is required. Up to 8,000 characters.

maxLength: 8000

input.aspect_ratio
required
string

Specifies the width-to-height ratio of the generated image. Controls the aspect ratio of the output. This field is required.

Values: "1:1", "2:3", "3:2", "16:9", "9:16"

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "grok-imagine-image-2-0/text-to-image",
  "input": {
    "prompt": "A small wooden cabin beside a calm lake at sunrise, soft mist over the water",
    "aspect_ratio": "1:1"
  }
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
optional
string

Response message, error description upon failure

data
required
object
data.taskId
required
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Task status and callbacks

For asynchronous tasks, keep the returned taskId. Query GET /api/v1/jobs/recordInfo?taskId=... or provide callBackUrl when creating the task. Only the account that created a task can access it or derive new resources from it.

A timeout can mean the submission was accepted. Inspect the existing request in your dashboard; do not create another task automatically. Callback delivery is retried and may arrive more than once. Deduplicate with X-VezAPI-Event-Id.

Files, logs and billing

Generated media normally follows a 14-day provider lifetime; uploaded files expire after 24 hours. Save the files you need before expiration. VezAPI streams registered files without keeping a permanent media library. Request logs are retained for two calendar months.

Credits are reserved before submission. Final deductions match actual discounted consumption one for one. Unknown usage pauses new paid requests. If available funds cannot cover final usage while protecting other reservations, settlement stays pending until funded; model usage cannot make the wallet negative. Time-based inputs require server-side metadata reads; a failed read prevents submission.