Skip to Content
ModelsNano BananaText to image & sizes

Nano Banana text to image & sizes

For model IDs and choosing an endpoint, see the Nano Banana overview.

Key pointThe aspect ratio is set by aspectRatio and the resolution by imageSize; both go in generationConfig.imageConfig.

Text to image example

nano_banana.py
import base64 from google import genai from google.genai import types client = genai.Client( api_key="YOUR_OFOX_API_KEY", http_options={"api_version": "v1beta", "base_url": "https://api.ofox.io/gemini"}, ) resp = client.models.generate_content( model="google/gemini-3.1-flash-image", contents="A red apple on a white table", config=types.GenerateContentConfig( response_modalities=["IMAGE"], image_config=types.ImageConfig(aspect_ratio="16:9", image_size="2K"), ), ) for part in resp.candidates[0].content.parts: if part.inline_data: with open("output.png", "wb") as f: f.write(part.inline_data.data)

In the Python SDK, inline_data.data is binary and can be written straight to a file; cURL returns a base64 string that must be decoded first.

Values supported by each model

Nano Banana 2.1Nano Banana 2Pro2 LiteNano Banana
imageSize1K, 2K, 4K512, 1K, 2K, 4K1K, 2K, 4K1K onlyNot supported; fixed at about 1K
10 common aspect ratiosSupportedSupportedSupportedSupportedSupported
1:4, 4:1, 1:8, 8:1SupportedSupportedNot supportedSupportedNot supported
Output formatPNGPNGPNGJPEGPNG

The 10 common aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. A ratio not on the list (e.g. 5:3) returns 400 Request contains an invalid argument.

Writing the resolution: use uppercase 1K, 2K, 4K for imageSize, matching Google’s official docs; in our tests OfoxAI also accepts lowercase. The 512 tier has no K unit.

Without imageConfig: the model decides the aspect ratio. Pass it explicitly if you need a fixed ratio.

Measured output sizes

ModelRequestActual outputLatency
Nano Banana 2.11:1 · 1K1024×1024~15 s
Nano Banana 2.11:8 · 1K352×2928~17 s
Nano Banana 2.11:1 · 4K4096×4096~140 s
Nano Banana 21:1 · 1K1024×1024~11 s
Nano Banana 216:9 · 1K1376×768~13 s
Nano Banana 21:8 · 512176×1456~9 s
Nano Banana 29:16 · 4K3072×5504, ~16 MB~28 s
Nano Banana Pro4:5 · 2K1856×2304~24 s
Nano Banana Pro16:9 · 4K5504×3072, ~16 MB~33 s
Nano Banana 2 Lite21:9 · 1K1584×672~5 s
Nano Banana21:91536×672~7 s

A 4K PNG is about 16 MB, so the base64-encoded response body exceeds 20 MB. Make sure your client, proxies and logging do not truncate large responses.

If you run into errors, see Troubleshooting errors.

Last updated on