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.
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" } ] }'{ "created": 1779703910, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..." } ], "usage": { "input_tokens": 712, "output_tokens": 1372, "total_tokens": 2084 }}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.
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"] }'{ "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" } ]}Quick map
| Model | Endpoint | Where to read the image |
|---|---|---|
| openai/gpt-image-2 | POST /v1/images/edits | data[0].b64_json |
| Gemini image models | POST /v1/chat/completions | choices[0].message.images[0].image_url.url |