Skip to main content
Grok Imagine Editing
Edit images with the xAI JSON request format. This endpoint does not use OpenAI multipart image uploads. POST https://api.mixroute.ai/v1/images/edits

Models

Request Parameters

Aspect Ratios

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, 21:9, 5:2 21:9 and 5:2 are Image 2.0 additions. Use the other supported ratios with earlier models. Use aspect_ratio and resolution, not the GPT Image size field. For editing, provide image or images. With multiple references, refer to them in order as <IMAGE_0>, <IMAGE_1>, and so on. Use direct JSON HTTP requests; the OpenAI SDK images.edit method sends multipart data and is not suitable for this xAI request.

Examples

Use your MixRoute key in the MIXROUTE_API_KEY environment variable. Requests use Authorization: Bearer .... Replace source-image placeholders with accessible images or local files before editing.

Python

Response

Read temporary image URLs from data[].url, or decode data[].b64_json without a data-URI prefix. mime_type identifies the encoding. When native storage is requested, file_output contains file information; a storage/public-URL error is distinct from generation failure. Grok image generation