Skip to content

Gemini image generation

Call Gemini image models via the official protocol. Text-to-image and image-to-image share the same endpoint; see Available models below for positioning and capability differences.

http
POST /v1beta/models/{model}:generateContent

Image-to-image does not need a different endpoint—append reference images as in .

Available models

ModelPositioning & capabilitiesOutput resolutionReference images
Flagship (Nano Banana Pro): professional asset production and complex multi-turn editing; strongest world knowledge and text rendering, finest composition and detail control; suited to posters, infographics, and accuracy-critical work / / Official limit 14 images
General workhorse (Nano Banana 2): balanced speed and quality; strong at multi-reference fusion and character consistency; only model in the family that supports extreme ratios , , , Supports / / / ; current channel is fixed around (ignores )Official limit 14 images
Previous generation (Nano Banana): speed and cost focused; suited to high-concurrency, low-latency bulk generationFixed (about )Official recommendation: no more than 3

Headers

NameTypeRequiredDescription
stringYesRequest authentication. Use a Bearer Token, for example:
stringYesRequest content type; must be

Request body

NameTypeRequiredDescription
arrayYesInput content array; usually a single element
objectNoGeneration config, including output modalities and image settings
arrayNoSafety filter settings; optional

contents item

NameTypeRequiredDescription
stringNoMessage role; fixed to
arrayYesContent parts array. Text-to-image uses only; for image-to-image, after append one per reference image (multiple supported)

parts.inlineData (reference image; image-to-image only)

NameTypeRequiredDescription
stringYesReference image MIME type: , ,
stringYesBase64-encoded reference image content

generationConfig.imageConfig

NameTypeRequiredDescription
arrayYesOutput modalities. Image generation must include ; recommended
stringNoOutput aspect ratio: , , , , , , , , , ; default . also supports extreme ratios , , ,
stringNoOutput resolution: , , ; default . Some models also support (0.5K, no K suffix). Note: Flash Image channels such as ignore this field and always return about 1K
numberNoSampling temperature, range to ; default
numberNoNucleus sampling parameter; default
integerNoTop-K sampling parameter
integerNoMaximum output tokens; for image generation, recommend at least
integerNoRandom seed. The same seed improves reproducibility

Request example

bash
curl -X POST https://octopusx.ai/v1beta/models/gemini-3-pro-image-preview:generateContent \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
  "contents": [{
    "role": "user",
    "parts": [
      { "text": "Futuristic AI workstation scene with cinematic lighting" }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["TEXT", "IMAGE"],
    "imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" }
  }
}'
bash
curl -X POST https://octopusx.ai/v1beta/models/gemini-3-pro-image-preview:generateContent \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
  "contents": [{
    "role": "user",
    "parts": [
      { "text": "Blend the reference styles and output a landscape poster" },
      { "inlineData": { "mimeType": "image/jpeg", "data": "BASE64_IMAGE_1" } },
      { "inlineData": { "mimeType": "image/jpeg", "data": "BASE64_IMAGE_2" } }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["TEXT", "IMAGE"],
    "imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" }
  }
}'

Response example

json
{
  "candidates": [{
    "content": {
      "role": "model",
      "parts": [
        { "inlineData": { "mimeType": "image/png", "data": "BASE64_OR_URL" } }
      ]
    },
    "finishReason": "STOP"
  }],
  "usageMetadata": {
    "promptTokenCount": 123,
    "candidatesTokenCount": 456,
    "totalTokenCount": 579
  },
  "modelVersion": "gemini-3-pro-image-preview"
}

Response fields

NameTypeDescription
arrayCandidate results array
stringFinish reason. means normal completion; means blocked by safety policy
objectGenerated image content
stringImage MIME type, usually
stringImage data as Base64 or an image URL; clients should handle both
integerInput token count
integerOutput token count
integerTotal token count
stringActual model version used