Image Generation API

Separate documentation for the OpenAI image API and the Gemini generateContent image API, with corrected model IDs, parameter names, endpoints, and response shapes.

Understand the two API families first

The most common documentation mistake is mixing OpenAI image parameters with Gemini image parameters. These official APIs are not interchangeable. Their endpoints, field names, model IDs, and response structures differ.

  • OpenAI official image API uses /v1/images/generations and /v1/images/edits.
  • Gemini official image API uses /v1/models/{model}:generateContent.
  • OpenAI commonly uses prompt, size, quality, and background.
  • Gemini commonly uses contents, parts, responseModalities, and responseFormat.image.

OpenAI official image API

POSThttps://img.gpt88.cc/v1/images/generations

Use the OpenAI image API for direct text-to-image generation. The official API distinguishes clearly between generations and edits.

import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({
  apiKey: process.env.GPT88_API_KEY,
  baseURL: "https://img.gpt88.cc",
});

const result = await client.images.generate({
  model: "gpt-image-2",
  prompt: "A children's book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter.",
  size: "1024x1024",
  quality: "high",
});

const imageBase64 = result.data[0].b64_json;
fs.writeFileSync("otter.png", Buffer.from(imageBase64, "base64"));

OpenAI image editing

POSThttps://img.gpt88.cc/v1/images/edits

The official edit endpoint supports editing existing images, generating from references, and localized edits with masks. Do not rewrite this as Gemini-style contents.parts.fileData, because that belongs to a different API family.

import base64
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_GPT88_API_KEY",
    base_url="https://img.gpt88.cc",
)

prompt = """
Generate a photorealistic image of a gift basket on a white background
labeled 'Relax & Unwind' with a ribbon and handwriting-like font,
containing all the items in the reference pictures.
"""

result = client.images.edit(
    model="gpt-image-2",
    image=[
        open("body-lotion.png", "rb"),
        open("soap.png", "rb"),
        open("bath-bomb.png", "rb"),
        open("incense-kit.png", "rb"),
    ],
    prompt=prompt,
    size="1536x1024",
    quality="high",
)

image_base64 = result.data[0].b64_json
with open("gift-basket.png", "wb") as f:
    f.write(base64.b64decode(image_base64))

Gemini official image API

POSThttps://img.gpt88.cc/v1/models/gemini-3.1-flash-image:generateContent

Gemini image generation uses generateContent. In current Google documentation, Nano Banana 2 maps to gemini-3.1-flash-image, while Nano Banana Pro maps togemini-3-pro-image. Gemini documentation describes output usingresponseFormat.image.aspectRatio and responseFormat.image.imageSize.

export API_KEY="YOUR_GPT88_API_KEY"
export BASE_URL="https://img.gpt88.cc"
export MODEL="gemini-3.1-flash-image"

curl -s -X POST \
  "$BASE_URL/v1/models/$MODEL:generateContent" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        { "text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme" }
      ]
    }],
    "generationConfig": {
      "responseModalities": ["IMAGE"],
      "responseFormat": {
        "image": {
          "aspectRatio": "16:9",
          "imageSize": "2K"
        }
      }
    }
  }' > response.json

jq -r '.. | objects | .inlineData?.data? | select(.)' response.json | head -n 1 | base64 -d > output.png

Gemini image-to-image and editing

For Gemini image-to-image flows, the more reliable official pattern is: upload the image first, then call generateContent. Do not document public image URLs as the primary input path here. Upload the file first, then pass the returned fileData.fileUri.

export API_KEY="YOUR_GPT88_API_KEY"
export BASE_URL="https://img.gpt88.cc"
export MODEL="gemini-3.1-flash-image"

# Upload the reference image first
curl -s -X POST "$BASE_URL/upload/v1/files" \
  -H "x-goog-api-key: $API_KEY" \
  -F "[email protected]" \
  -F "mimeType=image/png" > upload.json

FILE_URI=$(jq -r '.file.uri // .uri // .name' upload.json)

curl -s -X POST \
  "$BASE_URL/v1/models/$MODEL:generateContent" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"contents\": [{
      \"parts\": [
        { \"text\": \"Keep the main subject, change the background to a moonlit bamboo path\" },
        {
          \"fileData\": {
            \"mimeType\": \"image/png\",
            \"fileUri\": \"$FILE_URI\"
          }
        }
      ]
    }],
    \"generationConfig\": {
      \"responseModalities\": [\"TEXT\", \"IMAGE\"],
      \"responseFormat\": {
        \"image\": {
          \"aspectRatio\": \"1:1\",
          \"imageSize\": \"1K\"
        }
      }
    }
  }" > response.json

Field reference

OpenAI image API

  • modelstringRequired
    Official GPT Image model, such as gpt-image-2.
  • promptstringRequired
    Instruction for image generation or editing.
  • sizestring
    Pixel dimensions such as 1024x1024, 1536x1024, or 1024x1536. gpt-image-2 also supports more valid resolutions and auto.
  • qualitystring
    low, medium, high, or auto.
  • backgroundstring
    Official docs support opaque or auto. gpt-image-2 currently does not support transparent.
  • output_formatstring
    PNG by default. JPEG and WebP are also supported.
  • output_compressioninteger
    Available for JPEG / WebP, range 0-100.
  • ninteger
    Generate multiple images in one request. Default is 1.
  • imagefile | file[]
    Input image(s) for the edit endpoint /v1/images/edits.
  • maskfile
    Optional mask for localized editing. Only the masked region is changed.

Gemini image API

  • contentsarray<Content>Required
    Gemini generateContent input.
  • contents[].parts[].textstringRequired
    Prompt text.
  • contents[].parts[].inlineDataobject
    Reference images can be passed inline as base64 with mimeType and data.
  • contents[].parts[].fileDataobject
    Reference images can also be passed by uploaded fileUri.
  • generationConfig.responseModalitiesstring[]
    Common values are ["IMAGE"] or ["TEXT", "IMAGE"].
  • generationConfig.responseFormat.image.aspectRatiostring
    Official aspect-ratio enums such as 1:1, 16:9, 9:16, 4:3, or 3:4.
  • generationConfig.responseFormat.image.imageSizestring
    Some Gemini 3 image models support 1K, 2K, and 4K.

gpt88.cc compatibility notes

  • If you are using an OpenAI-compatible image model such as gpt-image-2, prefer /v1/images/generations and /v1/images/edits.
  • If you are using a Google / Gemini image model, prefer /v1/models/{model}:generateContent.
  • If the console shows a platform alias such as NanoBanana2, use the console model list as the source of truth, then map it to the relevant official API family.
  • For more entries, see Models and the Codex gpt-image-2 Skill guide.