# Nano Banana text to image: aspectRatio, imageSize, and the ratios and resolutions each model supports Source: https://ofox.ai/docs/develop/models/nano-banana/text-to-image For model IDs and choosing an endpoint, see the [Nano Banana overview](https://ofox.ai/docs/develop/models/nano-banana). **Key point**:The aspect ratio is set by `aspectRatio` and the resolution by `imageSize`; both go in `generationConfig.imageConfig`. ## Text to image example **Python** ```python filename="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.ai/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) ``` **cURL** ```bash filename="Terminal" curl 'https://api.ofox.ai/gemini/v1beta/models/google/gemini-3.1-flash-image:generateContent' \ --max-time 600 \ -H "x-goog-api-key: $OFOX_API_KEY" \ -H 'Content-Type: application/json' \ -d '{ "contents": [{ "parts": [{ "text": "A red apple on a white table" }] }], "generationConfig": { "responseModalities": ["IMAGE"], "imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" } } }' | jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' | base64 --decode > output.png ``` 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.1 | Nano Banana 2 | Pro | 2 Lite | Nano Banana | |---|---|---|---|---|---| | `imageSize` | `1K`, `2K`, `4K` | `512`, `1K`, `2K`, `4K` | `1K`, `2K`, `4K` | `1K` only | Not supported; fixed at about 1K | | 10 common aspect ratios | Supported | Supported | Supported | Supported | Supported | | `1:4`, `4:1`, `1:8`, `8:1` | Supported | Supported | Not supported | Supported | Not supported | | Output format | PNG | PNG | PNG | JPEG | PNG | 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 | Model | Request | Actual output | Latency | |---|---|---|---| | Nano Banana 2.1 | `1:1` · `1K` | 1024×1024 | ~15 s | | Nano Banana 2.1 | `1:8` · `1K` | 352×2928 | ~17 s | | Nano Banana 2.1 | `1:1` · `4K` | 4096×4096 | ~140 s | | Nano Banana 2 | `1:1` · `1K` | 1024×1024 | ~11 s | | Nano Banana 2 | `16:9` · `1K` | 1376×768 | ~13 s | | Nano Banana 2 | `1:8` · `512` | 176×1456 | ~9 s | | Nano Banana 2 | `9:16` · `4K` | 3072×5504, ~16 MB | ~28 s | | Nano Banana Pro | `4:5` · `2K` | 1856×2304 | ~24 s | | Nano Banana Pro | `16:9` · `4K` | 5504×3072, ~16 MB | ~33 s | | Nano Banana 2 Lite | `21:9` · `1K` | 1584×672 | ~5 s | | Nano Banana | `21:9` | 1536×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](https://ofox.ai/docs/develop/models/nano-banana/errors).