API documentation

Image Editing

Edit existing images with GPT Image or Gemini image models.

Image editing depends on the model type. GPT Image accepts edits through /v1/images/edits. Gemini image models work as chat models: the source image is sent inside the message, and the new image is returned in the chat response.

GPT Image

For GPT Image, send POST /v1/images/edits. Put the edit instruction in prompt and one or more source images in images. In JSON, use image_url; if the model supports file upload, multipart/form-data can be used too.

GPT Image request
curl https://api.aigate.shop/v1/images/edits \  -H "Authorization: Bearer sk-your-api-key" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-image-2",    "prompt": "Add a small orange cat sitting on the table. Keep the original lighting and style.",    "images": [      {        "image_url": "https://picsum.photos/seed/aigate-edit-test/800/600"      }    ]  }'
GPT Image response
{  "created": 1779703910,  "data": [    {      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."    }  ],  "usage": {    "input_tokens": 712,    "output_tokens": 1372,    "total_tokens": 2084  }}
Where the result is
The edited image is usually in data[0].b64_json. If the provider returns a link, it appears in data[0].url.

Gemini Images

Do not send Gemini image models to /v1/images/edits. They are text chat models that can return images, so use /v1/chat/completions for editing.

In messages.content, send two items: text with the edit instruction and image_url with the source image. Add modalities: ["image", "text"]. The response is in choices[0].message.images[0].image_url.url.

Gemini request
curl https://api.aigate.shop/v1/chat/completions \  -H "Authorization: Bearer sk-your-api-key" \  -H "Content-Type: application/json" \  -d '{    "model": "google/gemini-3.1-flash-image-preview",    "messages": [      {        "role": "user",        "content": [          {            "type": "text",            "text": "Edit this image: add a small orange cat sitting on the table. Keep the original lighting and style. Return the edited image."          },          {            "type": "image_url",            "image_url": {              "url": "https://picsum.photos/seed/aigate-edit-test/800/600"            }          }        ]      }    ],    "modalities": ["image", "text"]  }'
Gemini response
{  "id": "gate-1779703910",  "object": "chat.completion",  "created": 1779703910,  "model": "google/gemini-3.1-flash-image-preview",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": null,        "images": [          {            "type": "image_url",            "image_url": {              "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."            }          }        ]      },      "finish_reason": "stop"    }  ]}
Base64 response
Gemini usually returns a data URL like data:image/png;base64,... . To save the file, take the part after the comma and decode base64. content can be null for an image response.

Quick map

ModelEndpointWhere to read the image
openai/gpt-image-2POST /v1/images/editsdata[0].b64_json
Gemini image modelsPOST /v1/chat/completionschoices[0].message.images[0].image_url.url