GuideImage GenerationNano banana

Gemini Chat Format

Call Nano Banana image models via Gemini's native generateContent endpoint: request fields, aspect ratio and size config, chain-of-thought output, examples.

Gemini Content Generation (Gemini Native Format)

This endpoint calls Gemini native multimodal models (such as the Nano Banana series). It supports text generation, image generation, and returning the model's chain-of-thought process.


📌 Basics

  • Endpoint: POST /v1beta/models/{model}:generateContent/
  • Path parameters:
    • model: model name, e.g. gemini-3-pro-image-preview.
  • Authentication: Bearer Token
  • Content type: application/json

📥 Request Parameters (Request Body)

ParameterTypeRequiredDescription
contentsarrayYesList of conversation contents.
└─ rolestringNoRole (e.g. user).
└─ partsarrayYesList of message parts.
└─ └─ textstringYesPrompt or text input.
generationConfigobjectYesGeneration configuration object.
└─ responseModalitiesarrayYesResponse modalities. Allowed values: TEXT, IMAGE.
└─ thinkingConfigobjectNoThinking configuration.
└─ └─ includeThoughtsbooleanNoWhether to return the model's reasoning (chain of thought) during generation.
└─ imageConfigobjectYesImage generation configuration.
└─ └─ aspectRatiostringYesAspect ratio, e.g. 16:9, 1:1, 4:3.
└─ └─ imageSizestringYesImage quality/size, e.g. 4K, 1024x1024.

📤 Response

Status code: 200 OK

FieldTypeDescription
candidatesarrayList of generated candidates.
└─ contentobjectContains the generated role and the parts (may include text or image data).
└─ finishReasonstringReason generation stopped (e.g. STOP).
└─ safetyRatingsarraySafety evaluation ratings.
usageMetadataobjectToken usage metadata (Prompt, Candidates, Total).

📝 Request Example (Generate an Image)

{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "draw a futuristic city at sunset"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": ["TEXT", "IMAGE"],
    "imageConfig": {
      "aspectRatio": "16:9",
      "imageSize": "4K"
    },
    "thinkingConfig": {
      "includeThoughts": true
    }
  }
}

💡 Developer Tips

  1. Chain-of-thought output: By setting includeThoughts: true, you can see how the model interprets your request and "plans" before drawing — very useful when debugging complex prompts.
  2. Multimodal responses: When responseModalities includes both TEXT and IMAGE, the model first returns descriptive text and then generates the corresponding image.
  3. Model version: Make sure the {model} parameter in the path matches the API permissions you currently have.

On this page