The Nano Banana 2 API leverages the Gemini 3.1 Flash Image model to generate high-quality images from text prompts. It delivers fast, cost-efficient image generation with support for multiple resolutions up to 4K.
taskId.taskId to retrieve the generated images.Enum: application/json
Bearer authentication token. Example: Bearer {{APIKey}}.
The model identifier. Must be set to gemini-3.1-flash-image for Nano Banana 2.
The text prompt describing the image to generate. Example: "The kitten is eating".
The output image resolution. Supported values for Nano Banana 2: "512", "1K", "2K", "4K". Default: "1K".
The aspect ratio of the generated image. Example: "16:9", "1:1", "4:3".
An array of reference image URLs for image-to-image generation. Can be empty or omitted. Example: ["https://d2t5pyzt5qvy2d.cloudfront.net/..."].
Returns 0 for success, or a specific error code.
Returns "success" or a descriptive error message.
The unique identifier for the task. Use this ID with the Polling API to retrieve the generated output.
Use the Polling API to retrieve the processing results.
Alternatively, you can enable Callback to receive task results automatically on completion.
{
"code": 0,
"message": "success",
"data": {
"images": [
{
"imageUrl": "https://dreamface-resource.oss-us-east-1.aliyuncs.com/df-ability-tmp/0a2f83e6-21e7-47c7-ab50-74457845d628.jpeg",
"imageType": "png"
}
],
"task": {
"taskId": "API-605f75923ff64b998955ba46f13915f2",
"status": 3,
"errorCode": 0,
"reason": "ok",
"taskType": "google_gemini_image",
"executionTime": 26446,
"expire": 1778593345400
}
}
}curl -X POST 'https://api.newportai.com/api/async/google_gemini_image' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{APIKey}}' \
-d '{
"model": "gemini-3.1-flash-image",
"text": "The kitten is eating",
"aspectRatio": "16:9",
"imageSize": "1K",
"images": [
"https://d2t5pyzt5qvy2d.cloudfront.net/api/static_resource/prod/default/VE-i9SzS3ZRdVTSzJWTcA.jpeg"
]
}'{
"code": 0,
"message": "success",
"data": {
"taskId": "API-605f75923ff64b998955ba46f13915f2"
}
}