Grok Imagine Image 2.0 Segment Edit
Endpoint
POST /images/generations
Full URL: https://modelfold.ai/v1/images/generations
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
Send model parameters directly in the JSON body. Do not wrap them in input. This request waits for generation to finish and returns data[].url; supported media models also offer async jobs, polling and callbacks. Replace example media URLs with your own publicly accessible files. See API gateway for billing and errors.
Input parameters for the Grok Imagine image editing task.
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name used for generation. This field is required. This endpoint must use the grok-imagine-image-2-0/segment-edit model. Default:"grok-imagine-image-2-0/segment-edit"。 Allowed values:grok-imagine-image-2-0/segment-edit。 Example:grok-imagine-image-2-0/segment-edit。 |
prompt | string | Yes | Prompt required by the ModelFold gateway; at most 2000 characters. Text prompt describing the desired image. Up to 65,000 characters. maxLength: 2000. Example:Change the background to a sunset beach while preserving the subject.。 |
task_id | string | Yes | 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.). Example:task_grok_imagine_1234567890。 |
mask_indexs | array<integer> | No | 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
bash
curl -X POST "https://modelfold.ai/v1/images/generations" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2-0/segment-edit",
"prompt": "Change the background to a sunset beach while preserving the subject.",
"task_id": "task_grok_imagine_1234567890"
}'json
{
"model": "grok-imagine-image-2-0/segment-edit",
"prompt": "Change the background to a sunset beach while preserving the subject.",
"task_id": "task_grok_imagine_1234567890"
}Response
200 — Generation completed. usage contains actual billing details; result URLs are illustrative.
json
{
"ok": true,
"created": 1792134000,
"data": [
{
"url": "https://modelfold.ai/uploads/outputs/result.png"
}
],
"usage": {}
}