API Notes
nano_banana_2_lite maps to the official Gemini model gemini-3.1-flash-lite-image and supports text-to-image generation and image editing
nano_banana_2_lite is optimized for low-latency, cost-efficient, high-throughput workloads and uses 1K image output size
Authentication
authorization string required
All APIs require authentication via Bearer Token.
Get API Key:
Visit API Key Management Page to get your API Key.
Usage:
Add to request header:
Authorization: Bearer YOUR_API_KEY
Parameters
model string required
Model ID to use for the request
Value: nano_banana_2_lite
prompt string required
Text prompt describing the image to generate or edit
image_urls array
List of input image URLs used for image editing
aspect_ratio string
Image aspect ratio
Options: 1:8, 1:4, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 8:1, 4:1, 9:16, 16:9, 21:9
image_size string
Image output size
Options: 1K
Synchronous generation
Send the same request body to POST /model/v1/generation/sync. The request waits for the task to finish and returns the terminal response directly without an additional task submission
Polling
Since result generation takes time, you need to poll the task status after creating the task.
The initial response only returns information such as the task ID and initial status. The final result must be obtained by polling the task status endpoint using the task ID.
See the examples on the right for polling requests and responses.
Response Format
error object
Error information, only present when status is failed
code
stringError code
message
stringDetailed error message
output array
Generation results, only present when status is completed
content
arrayList of generated resource content
type
stringResource type
Value:
image|videourl
stringProcessed resource URL
jobId
stringRemote task ID
usage object
Usage statistics, only present when status is completed
cost
stringTotal cost in USD
discount
numberDiscount amount
metadata object
Metadata information
Nano Banana 2 Lite also returns the following token fields in usage
prompt_tokens
integerNumber of tokens consumed by the input prompt and images
completion_tokens
integerNumber of tokens consumed by the generated result
total_tokens
integerTotal token count
Error Codes
| Error Code | Description |
|---|---|
| 005001095 | Internal generation error |
| 005001096 | Result parsing error |
| 005001097 | HTTP error response |
| 005001098 | Synchronous generation error |