API documentation

Image Overview

Which endpoint to use for GPT Image and Gemini image models, and where generated images appear in responses.

AIGate has two different image patterns. GPT Image uses /v1/images/generations and /v1/images/edits. Gemini image models work as chat models: use /v1/chat/completions for both generation and editing.

Where to send the request

ModelEndpointImage location
openai/gpt-image-2POST /v1/images/generationsdata[0].b64_json or data[0].url
openai/gpt-image-2 editPOST /v1/images/editsdata[0].b64_json or data[0].url
google/gemini-3.1-flash-image-previewPOST /v1/chat/completionschoices[0].message.images[0].image_url.url
google/gemini-3-pro-imagePOST /v1/chat/completionschoices[0].message.images[0].image_url.url

Image editing

For GPT Image, send the source image in images to /v1/images/edits. For Gemini image models, put the source image as image_url inside messages and put the edit instruction as text in the same message.

Do not mix routes
Do not send Gemini image models to /v1/images/generations or /v1/images/edits. Use /v1/chat/completions with modalities: ["image", "text"].

How to save the result

ts
import { writeFileSync } from "node:fs";function saveDataUrl(url: string, filename: string) {  const [, base64] = url.split(",");  writeFileSync(filename, Buffer.from(base64, "base64"));}