Edit Grok Image

POST/v1/images/edits
Edit one or more reference images with a Grok image model.

Request Body

application/json
prompt:requiredstring

Text instruction describing the requested output.

ExampleRender this as a pencil sketch with detailed shading
aspect_ratio:requiredstring

Aspect ratio of the generated media.

Allowed1:13:44:39:1616:92:33:29:19.519.5:99:2020:91:22:1auto
Exampleauto
image:requiredobject

Input image used for editing or generation.

Example{"url":"https://docs.x.ai/assets/api-examples/images/style-realistic.png","type":"image_url"}
images:requiredarray

Input images used for multi-reference editing.

model:requiredstring

Model identifier used for this request.

Examplegrok-imagine-image-quality
n:requiredinteger

Number of results to generate.

resolution:requiredstring

Resolution of the generated media.

Allowed1k2k
response_format:requiredstring

Format used to return generated media.

Allowedurlb64_json
Exampleurl

Response

200

A successful request returns a JSON response. The complete example is shown in the code panel.