Image / Nano Banana

Nano Banana Official Image Generation

asGemini localized example text (generateContent image, can use Gemini SDK).OpenAI Images endpoint, task booking orNano Banana Official OpenAI localized example text.task and, can.

Overview

Nano Banana Official Nano Banana endpoint, token.and Nano Banana (/api/v2/open/aigc/nano-banana-*), Parameter and Billing Method,.

localized example text:
- 🔌 localized example text:Request Bodyand and GeminigenerateContent, SDK Base URL
-⚡ image:Request return image (inlineData base64), no Polling
-🖼️ image reference:up to 14 images Reference image, supported URL and base64
-🧠 can:thinkingLevel (Pro Model)
-📐 15 Aspect ratio+ height 4K:localized example text1:8 image8:1 localized example textBase URL: https://mm-internal-cn.leonecloud.com


Authentication

Method:``
x-goog-api-key: {YOUR_API_KEY}
Authorization: Bearer {YOUR_API_KEY}
?key={YOUR_API_KEY} # Query Parameters, REST
``

Failurereturned when applicable HTTP 401:```json
{
"error": {
"code": 401,
"message": "API Key no",
"status": "UNAUTHENTICATED"
}
}


---

## model Values

`model` in RequestPath:`/v1beta/models/{model}:generateContent`.Model, Request Bodyexactly identical, with, and Values:| model | Resolutionlocalized example text`imageSize` | Aspect ratio | localized example text`thinkingLevel` | Parameter| output token|
|-------|-----|-----|-----|-----|-----|
| `nano-banana-pro-official` | `1K` / `2K` / `4K` | 15 localized example text| can (Model)| supported| 32768 |
| `nano-banana-2-1-official` | `1K` / `2K` / `4K` | 15 localized example text| `MINIMAL` / `MEDIUM` / `HIGH` | **supported** | 32768 |
| `nano-banana-2-official` | `512` / `1K` / `2K` / `4K` | 15 localized example text| `MINIMAL` / `HIGH` | supported| 32768 |
| `nano-banana-2-lite-official` | only `1K` | 14 ( no`9:21`) | `MINIMAL` / `HIGH` | supported| 4096 |

15 Aspect ratio:`1:1`, `3:2`, `2:3`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`, `9:21`, `1:4`, `4:1`, `1:8`, `8:1`.

Parameter`temperature` / `topP` / `topK` / `seed`.localized example text`model`, Pricing.Pathin the`model` in returned when applicable HTTP 404.

---

## Default

| field | Default | Description |
|------|--------|------|
| `imageConfig.imageSize` | `1K` | |
| `imageConfig.aspectRatio` | If omitted | ModelPrompt and Reference image|
| `thinkingConfig.thinkingLevel` | `nano-banana-2-1-official` as`MEDIUM`; `nano-banana-2-official` / `nano-banana-2-lite-official` as`MINIMAL` | Pro can|
| `imageConfig.imageOutputOptions.mimeType` | `image/png` | |
| `maxOutputTokens` | Model output token|, and image|
| `responseModalities` | `["TEXT", "IMAGE"]` | must`IMAGE`; localized example text`["IMAGE"]` when return Description|

---

## Supported Scenarios

### Scenario1:Text-to-Image

```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/v1beta/models/nano-banana-pro-official:generateContent" \
-H "x-goog-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{ "role": "user", "parts": [{ "text": "when,," }] }
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" }
}
}'


### Scenario2:Image-to-Image (Reference image URL)

Reference imagelocalized example text`fileData.fileUri` can http/https:```bash
curl -X POST "https://mm-internal-cn.leonecloud.com/v1beta/models/nano-banana-2-1-official:generateContent" \
 -H "x-goog-api-key: your_api_key_here" \
 -H "Content-Type: application/json" \
 -d '{
 "contents": [{
 "role": "user",
 "parts": [
 { "text": "subject," },
 { "fileData": { "mimeType": "image/png", "fileUri": "https://example.com/portrait.png" } }
 ]
 }],
 "generationConfig": {
 "responseModalities": ["TEXT", "IMAGE"],
 "thinkingConfig": { "thinkingLevel": "HIGH" },
 "imageConfig": { "imageSize": "2K" }
 }
 }'

Scenario3:Image-to-Image (Reference image base64)

Reference imagelocalized example textinlineData, file:```json
{
"contents": [{
"role": "user",
"parts": [
{ "text": "repair," },
{ "inlineData": { "mimeType": "image/jpeg", "data": "BASE64_IMAGE_DATA" } }
]
}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": { "imageSize": "1K" }
}
}


### Scenario4:image+ localized example text```json
{
 "systemInstruction": { "parts": [{ "text": "output," }] },
 "contents": [{
 "role": "user",
 "parts": [
 { "text": "number images image number images image Scenario, consistent" },
 { "fileData": { "fileUri": "https://example.com/person.png" } },
 { "fileData": { "fileUri": "https://example.com/scene.jpg" } }
 ]
 }],
 "generationConfig": {
 "responseModalities": ["TEXT", "IMAGE"],
 "imageConfig": { "aspectRatio": "3:4", "imageSize": "2K" }
 }
}

Scenario5:output JPEG and```json { "contents": [{ "role": "user", "parts": [{ "text": ",, image" }] }], "generationConfig": { "responseModalities": ["TEXT", "IMAGE"], "imageConfig": { "aspectRatio": "9:16", "imageSize": "4K", "imageOutputOptions": { "mimeType": "image/jpeg", "compressionQuality": 90 } } } }


### Scenario6:use Gemini SDK (Python)```python
from google import genai
from google.genai import types

client = genai.Client(
 api_key="your_api_key_here",
 http_options=types.HttpOptions(base_url="https://mm-internal-cn.leonecloud.com"),
)

resp = client.models.generate_content(
 model="nano-banana-2-official",
 contents="in,",
 config=types.Generate ContentConfig(
 response_modalities=["TEXT", "IMAGE"],
 thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
 image_config=types.ImageConfig(aspect_ratio="16:9", image_size="2K"),
 ),
)
for part in resp.candidates[0].content.parts:
 if part.inline_data:
 open("output.png", "wb").write(part.inline_data.data)

with Gemini SDK when,base_url, api_key andmodel localized example text.


Endpoint details

image**POST** /v1beta/models/{model}:generateContent

Content-Type: application/json

endpointaslocalized example text: image after return, maximum etc. 10 minutes.

Request Parameters

ParameterTypeRequiredDescription
contentsarrayYessupported:role asuser (or If omittedrole)Content item,parts localized example textparts Content item
systemInstructionobjectNo,{"parts": [{"text": "..."}]}, in thetext, maximum 8,000 characters
generationConfigobjectNo,generationConfig
safetySettingsarrayNo,[{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_ONLY_HIGH"}], up to 16 localized example text
toolsarrayNosupported, return 400
contents / generationConfig / imageConfig / thinkingConfig etc. field, camelCase (inlineData)and snake_case (inline_data)localized example textlocalized example text, and SDK and REST; when camelCase as.

parts Content item

Typelocalized example textDescription
localized example text{"text": "Prompt"}must; and Reference image, maximum 32,000 characters
Reference image (URL){"fileData": {"mimeType": "image/png", "fileUri": "https://..."}}onlysupported http/https,mimeType can
Reference image (base64){"inlineData": {"mimeType": "image/jpeg", "data": "BASE64"}}imagedata

Reference imagecan,up to 14 images; single imageexceeds 7MB, supported PNG / JPEG / WebP / HEIC / HEIF.Reference image as Image-to-Image, no field.multiple imagesReference imagewhen, in Prompt「number images image」「number images image」localized example text.

and Reference image inparts after willlocalized example text, image when can Description in Reference image after,[image 1,"number images image…", image 2,"number images image…"].

generationConfig

fieldTypeDescription
responseModalitiesstring[]localized example textIMAGE, localized example text["TEXT", "IMAGE"]; localized example text["IMAGE"] when return Description
candidateCountintegersupported1, Request 1 images
imageConfig.aspectRatiostringAspect ratio, Valueslocalized example textmodel Values; If omittedModel
imageConfig.imageSizestringResolutionlocalized example text512 / 1K / 2K / 4K (K), default1K
imageConfig.personGenerationstring:ALLOW_ALL / ALLOW_ADULT / ALLOW_NONE
imageConfig.prominentPeoplestring:ALLOW_PROMINENT_PEOPLE / BLOCK_PROMINENT_PEOPLE
imageConfig.imageOutputOptions.mimeTypestringOutput format image/png (default)/ image/jpeg
imageConfig.imageOutputOptions.compressionQualityintegerJPEG quality 0–100, only image/jpeg when valid
thinkingConfig.thinkingLevelstring, Valuesmodel Values;nano-banana-pro-official will return 400
thinkingConfig.includeThoughtsbooleanin in return, defaultfalse
temperaturenumber0–2
topPnumber(0, 1]
topKintegerlocalized example text
seedintegerrandom seed
maxOutputTokensintegeroutput token (+ localized example text+ image), range 1 Model
Description:
- nano-banana-2-1-official supported Parameter:localized example texttemperature / topP / topK / seed return 400.
- supportedthinkingBudget:localized example textthinkingLevel.
- PNG as no,mimeType asimage/png whencompressionQuality 100 will return 400.
- supported Mask (mask), when in Prompt in.

Response Parameters

Successreturn HTTP 200, as GeminiGenerate ContentResponse:

ParameterTypeDescription
candidates[].content.parts[]arraylocalized example text.imagelocalized example textinlineData (mimeType + base64 data)return; Model Descriptiontext return;includeThoughts whenthought: true localized example texttext return
candidates[].finishReasonstring, asSTOP
usageMetadataobjecttoken, as,Billing
modelVersionstringlocalized example textmodel (and RequestPath)
responseIdstringTask ID, can use query and

localized example textX-Task-Id andresponseId as Task ID.in returnthoughtSignature.

Response Example

{
 "candidates": [
 {
 "content": {
 "role": "model",
 "parts": [
 { "text": "as." },
 {
 "inlineData": {
 "mimeType": "image/png",
 "data": "iVBORw0KGgoAAAANSUhEUgAA..."
 }
 }
 ]
 },
 "finishReason": "STOP"
 }
 ],
 "usageMetadata": {
 "promptTokenCount": 18,
 "candidatesTokenCount": 1130,
 "thoughtsTokenCount": 264,
 "totalTokenCount": 1412,
 "promptTokensDetails": [{ "modality": "TEXT", "tokenCount": 18 }],
 "candidatesTokensDetails": [
 { "modality": "TEXT", "tokenCount": 10 },
 { "modality": "IMAGE", "tokenCount": 1120 }
 ]
 },
 "modelVersion": "nano-banana-pro-official",
 "responseId": "task_20261029120000_abc12345"
}

Query TaskRequest when (504) or in when, task in after execute, can Task ID query results:**GET** /v1/images/generations/{taskId}

curl -X GET "https://mm-internal-cn.leonecloud.com/v1/images/generations/task_20261029120000_abc12345" \
 -H "Authorization: Bearer your_api_key_here"
query endpointAuthorization: Bearer Requestlocalized example text.Successwhendata.result as image URL list,data.output as generateContent (imagefileData.fileUri ).fieldOpenAI localized example text· Query Task.

Error Codes

Erroras Gemini Format:```json
{
"error": {
"code": 400,
"message": "Aspect ratio 2:5 supported, Optional:1:1 / 3:2 /...",
"status": "INVALID_ARGUMENT"
}
}


| HTTP | error.status | Description |
|------|-----------|------|
| 400 | `INVALID_ARGUMENT` | ParameterError (Promptas or, Reference image exceeds 14 images, Aspect ratio / in ModelOptionalrange,`role` as`user` etc. ); or task, Reference image no, output token, Model not image Failure|
| 401 | `UNAUTHENTICATED` | API Key invalid or missing |
| 403 | `PERMISSION_DENIED` | no|
| 404 | `NOT_FOUND` | Modelin or PathError|
| 413 | `INTERNAL` | Request Body(base64 Reference image when, recommended`fileData.fileUri` URL)|
| 429 | `RESOURCE_EXHAUSTED` | Insufficient balanceor|
| 500 | `INTERNAL` | Error, can|
| 503 | `UNAVAILABLE` | Modelcan use, after|
| 504 | `DEADLINE_EXCEEDED` | etc. exceeds 10 minutes, task in execute, can use[Query Tasklocalized example text](#Query Task) image|

taskcreate after Failure (400 / 500),`X-Task-Id`, and.recommendedHTTP Status Code ( can / Parameter / ),`error.message`.

---

## Billing

token,:

-**input**:Promptand; 
-**imageinput**:Reference image, images height; 
-**output**:Modeland (`thoughtsTokenCount` ); 
-**imageoutput**:image, Resolution height height.

Requestwhen, image after in`usageMetadata`; taskFailure, Parameter RequestCreate Task,.

height, output token; image qualityRequirements height Scenario, recommended use`thinkingLevel`.localized example text「localized example text」as.

---

## Best Practices

### 1. Model-, image, image→ `nano-banana-pro-official`
- and Requirements height,→ `nano-banana-2-1-official`
- 512 image or 4K image,→ `nano-banana-2-official`
-,→ `nano-banana-2-lite-official`

### 2. when 

Request maximum 10 minutes, 4K and height when.HTTP when recommended as**10 minuteslocalized example text**; must,`X-Task-Id`, when after[Query Tasklocalized example text](#Query Task) image.or Callback Notification when, recommended[OpenAI localized example text](/docs/nano-banana-official-v1).

### 3. Prompt Tips

- use,, can, and 
- Image-to-Image when**localized example text**, image 
- multiple imagesReference image when,「number images image」「number images image」each image 

---## FAQ

### Q1: supported`streamGenerateContent` localized example text?

**A**: supported,`:streamGenerateContent` return 400.use`:generateContent`.

### Q2: supported?

**A**: supported.`contents` in`role: model` return 400, return`thoughtSignature`.in images image when, images image as Reference image, in PromptRequirements, Request.

### Q3: localized example text`modelVersion` and`responseId` localized example text?

**A**: `modelVersion` RequestPath in the`model`; `responseId` Task ID, and`X-Task-Id`, can use query and.

### Q4: and OpenAI with?

**A**: Model, ParameterCapabilityand exactly identical, Method: return base64 image, use Gemini SDK;[OpenAI localized example text](/docs/nano-banana-official-v1) task booking, return image URL, supported`callback_url` localized example text.task can query endpoint query.

### Q5: `thinkingLevel` localized example text?

**A**: Model:`nano-banana-pro-official` supported (); Model Values[model Values](#model-),`MEDIUM` only `nano-banana-2-1-official` supported.

---

## Technical Support

If you have any questions, please contact our technical support team.
Updated 2026-11-15