Grok Imagine Image 2.0 Edit
Model ID xai/grok-imagine-image-2.0/edit
Overview
Image editing from 1 to 5 source images with natural-language instructions.
Endpoint
POST /v1/images/generations/async
Authentication
Authorization: Bearer <AIAPIAIAPI_API_KEY>
Request Body
| Parameter | Type | Required | Nullable | Default | Constraints | Description |
|---|---|---|---|---|---|---|
model | string | Yes | No | - | values: xai/grok-imagine-image-2.0/edit | Model ID used to route the request. |
prompt | string | Yes | No | - | - | Image generation or editing prompt, up to 8000 characters. |
images | array | Yes | No | - | min_items: 1; max_count: 5; accepts: URL, Base64 data URL | Source images. Refer to them as <IMAGE_0> through <IMAGE_4> in the prompt. Input images are charged by the provider separately from outputs. |
resolution | string | No | No | `1k` | values: 1k, 2k | Output image resolution. |
aspect_ratio | string | No | No | `auto` | values: auto, 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1 | auto lets the model choose; output generally follows the first source image's aspect ratio. |
n | integer | No | No | `1` | range: 1-4 | Number of output images. Each image is billed separately. |
quality | string | No | No | `medium` | values: low, medium | Image rendering quality tier. |
model
Type: string · Required: Yes · Nullable: No
Model ID used to route the request.
prompt
Type: string · Required: Yes · Nullable: No
Image generation or editing prompt, up to 8000 characters.
images
Type: array · Required: Yes · Nullable: No
Source images. Refer to them as <IMAGE_0> through <IMAGE_4> in the prompt. Input images are charged by the provider separately from outputs.
resolution
Type: string · Required: No · Nullable: No
Output image resolution.
aspect_ratio
Type: string · Required: No · Nullable: No
auto lets the model choose; output generally follows the first source image's aspect ratio.
n
Type: integer · Required: No · Nullable: No
Number of output images. Each image is billed separately.
quality
Type: string · Required: No · Nullable: No
Image rendering quality tier.
Request Example
curl --request POST \
--url https://aiapiaiapi.com/v1/images/generations/async \
--header 'Authorization: Bearer $AIAPIAIAPI_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "xai/grok-imagine-image-2.0/edit",
"prompt": "A cinematic camera movement through a forest",
"images": ["https://example.com/reference.jpg"],
"resolution": "1k"
}'JSON
{
"model": "xai/grok-imagine-image-2.0/edit",
"prompt": "A cinematic camera movement through a forest",
"images": ["https://example.com/reference.jpg"],
"resolution": "1k"
}Response
{
"code": "success",
"message": "",
"data": { "task_id": "image_01K2ABC123" }
}Task Status
Use the task_id from the create response:
GET /v1/images/generations/async/{task_id}
{
"code": "success",
"message": "",
"data": {
"task_id": "image_01K2ABC123",
"status": "SUCCESS",
"progress": "100%",
"outputs": ["https://cdn.example.com/images/image_01K2ABC123.png"],
"start_time": 1786960805,
"finish_time": 1786960900,
"submit_time": 1786960800,
"fail_reason": ""
}
}Error Responses
Validation errors return HTTP 400 with a stable error code.
{
"code": "unsupported_parameter",
"message": "The parameter is not supported by this model.",
"data": null
}Documentation Index
Fetch the complete documentation index at:
https://aiapiaiapi.com/llms.txt
Use this file to discover all available API documentation.