Skip to Content
API CallImage Generationgemini-3-pro-image (Nano Banana 2)

gemini-3-pro-image (nano banana 2)

This document introduces the input and output parameters for the API of the gemini-3-pro-image-preview (Model ID: gemini-3-pro-image-preview) model. Use this for reference when utilizing the API.


Only some of the fields used are displayed below. For detailed explanations, please refer to the official documentation New Features in Gemini 3 Pro Image.

Request Parameters

Request Body

Field NameTypeRequiredDefault ValueDescription
contentsarrayRequired-The requested content, containing one or more parts.
contents.rolestringRequired”user”The role of the content, fixed as “user” here.
contents.partsarrayRequired-Specific parts of the content.
contents.parts.textstringOptional-Prompt text.
generationConfigobjectOptional-Generation configuration.
generationConfig.responseModalitiesarrayOptional[“TEXT”, “IMAGE”]Desired response forms, either text or image.
generationConfig.imageConfigobjectOptional-Image generation configuration.
generationConfig.imageConfig.aspectRatiostringOptional”1:1”Image aspect ratio. Supports “1:1”, “2:3”, “3:2”, “3:4”, “4:3”, “4:5”, “5:4”, “9:16”, “16:9”, “21:9”.
generationConfig.imageConfig.imageSizestringOptional”1K”Image resolution. Supports “1K”, “2K”, “4K”.

Response Parameters

Field NameTypeDescription
candidatesarrayList of returned candidate content.
candidates.contentobjectCandidate content.
candidates.content.partsarraySpecific parts of content, may contain text and image data.
candidates.content.parts.textstringText description returned by the model.
candidates.content.parts.inlineDataobjectInline image data.
candidates.content.parts.inlineData.datastringBase64-encoded image data.
candidates.content.parts.inlineData.mimeTypestringMIME type of data, e.g., “image/png”.
candidates.finishReasonstringReason for generation ending, e.g., “STOP”.
usageMetadataobjectMetadata on token usage.
errorObjectError information object.

Examples

Gemini Compatible Interface

POST https://api.umodelverse.ai/v1beta/models/gemini-3-pro-image-preview:generateContent

Image Generation (Text to Image)

⚠️ Note: You must include responseModalities: [“TEXT”, “IMAGE”] in the configuration.

** curl **
curl -s -X POST \ "https://api.umodelverse.ai/v1beta/models/gemini-3-pro-image-preview:generateContent" \ -H "x-goog-api-key: $MODELVERSE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{"parts": [{"text": "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English."}]}], "tools": [{"google_search": {}}], "generationConfig": { "responseModalities": ["TEXT", "IMAGE"], "imageConfig": {"aspectRatio": "1:1", "imageSize": "1K"} } }' | jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' | head -1 | base64 --decode > butterfly.png
** python **
from google import genai from google.genai import types import os client = genai.Client( api_key=os.getenv("MODELVERSE_API_KEY", "<MODELVERSE_API_KEY>"), # Your API_KEY http_options=types.HttpOptions( base_url="https://api.umodelverse.ai" ), ) prompt = "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English." aspect_ratio = "1:1" # "1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9" resolution = "1K" # "1K", "2K", "4K" response = client.models.generate_content( model="gemini-3-pro-image-preview", contents=prompt, config=types.GenerateContentConfig( response_modalities=["TEXT", "IMAGE"], image_config=types.ImageConfig( aspect_ratio=aspect_ratio, image_size=resolution ), ), ) for part in response.parts: if part.text is not None: print(part.text) elif image := part.as_image(): image.save("butterfly.png")

Response Example

{ "candidates": [ { "content": { "parts": [ { "text": "Here is the anatomical sketch of a dissected Monarch butterfly in Da Vinci style..." }, { "inlineData": { "data": "iVBORw0KGgoAAAANSUhEUgAA...", "mimeType": "image/png" } } ], "role": "model" }, "finishReason": "STOP" } ], "usageMetadata": { "candidatesTokenCount": 1315, "totalTokenCount": 1331 } }
{ "error": { "message": "error_message", "type": "error_type", "param": "request_id", "code": "error_code" } }