Generate Images Using Nano Banana
Follow this recipes to generate images using the Nano Banana model.
Generate Image from Text Prompts
The guide will recreate the following functionality in the Web UI via API.
Note: This model is using the V2 endpoint:
https://cloud.leonardo.ai/api/rest/v2/generations.
Sample Request
curl --location 'https://cloud.leonardo.ai/api/rest/v2/generations' \
--header 'authorization: Bearer {api-key}' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-2.5-flash-image",
"parameters": {
"width": 1024,
"height": 1024,
"prompt": "a portrait-style photograph featuring a koala sitting against a neutral beige background. The koala has soft, fluffy gray fur with a lighter patch on its chest and around its nose. Its ears are large and fluffy, adding to its endearing look. The lighting is soft, highlighting the texture of the fur. The overall composition is centered, with the koala directly facing the camera, creating a charming and engaging image",
"quantity": 1,
"style_ids": [
"111dc692-d470-4eec-b791-3475abac4c46"
],
"prompt_enhance": "OFF"
},
"public": false
}
'
Sample Output

Number Of Reference ImageNano Banana can support up to 6 reference images.
Generate from Image Reference with Generated Image
Sample Request
curl --location 'https://cloud.leonardo.ai/api/rest/v2/generations' \
--header 'authorization: Bearer {api-key}' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-2.5-flash-image",
"parameters": {
"width": 1024,
"height": 1024,
"prompt": "a koala with a purple scarf",
"quantity": 1,
"guidances": {
"image_reference": [
{
"image": {
"id": "fc6f78c6-e7ac-491b-ad26-01f6843db870",
"type": "GENERATED"
},
"strength": "MID"
},
{
"image": {
"id": "a8e374dd-52f8-4236-ad9e-99b1f601fa3a",
"type": "GENERATED"
},
"strength": "MID"
}
]
},
"style_ids": [
"111dc692-d470-4eec-b791-3475abac4c46"
],
"prompt_enhance": "OFF"
},
"public": false
}
'
Input Image 1

Input Image 2
Sample Output

Generate from Image Reference with Uploaded Image
Sample Request
curl
--location 'https://cloud.leonardo.ai/api/rest/v2/generations' \
--header 'authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-2.5-flash-image",
"parameters": {
"width": 1024,
"height": 1024,
"prompt": "A koala wearing a purple scarf and a big wizard hat.",
"quantity": 1,
"guidances": {
"image_reference": [
{
"image": {
"id": "fc6f78c6-e7ac-491b-ad26-01f6843db870",
"type": "GENERATED"
},
"strength": "MID"
},
{
"image": {
"id": "a8e374dd-52f8-4236-ad9e-99b1f601fa3a",
"type": "GENERATED"
},
"strength": "MID"
},
{
"image": {
"id": "56c2f4d6-5fef-46db-a1e5-a7d3ec5054c3",
"type": "UPLOADED"
},
"strength": "MID"
}
]
},
"style_ids": [
"111dc692-d470-4eec-b791-3475abac4c46"
],
"prompt_enhance": "OFF"
},
"public": false
}
'
Input Uploaded Image

Sample Output

Required Parameters
-
modelId
Model Model ID Nano Banana gemini-2.5-flash-image -
prompt - Text prompt to use for generation.
Supported Parameters
-
prompt_enhance - Boolean to enable AI prompt enhancement
-
quantity - Number of images - default: 1, max: 8
-
style_ids (Preset Style)
Preset Style UUID 3D Render debdf72a-91a4-467b-bf61-cc02bdeb69c6 Acrylic 3cbb655a-7ca4-463f-b697-8a03ad67327c Creative 6fedbf1f-4a17-45ec-84fb-92fe524a29ef Dynamic 111dc692-d470-4eec-b791-3475abac4c46 Fashion 594c4a08-a522-4e0e-b7ff-e4dac4b6b622 Game Concept 09d2b5b5-d7c5-4c02-905d-9f84051640f4 Graphic Design 2D 703d6fe5-7f1c-4a9e-8da0-5331f214d5cf Graphic Design 3D 7d7c2bc5-4b12-4ac3-81a9-630057e9e89f Illustration 645e4195-f63d-4715-a3f2-3fb1e6eb8c70 None 556c1ee5-ec38-42e8-955a-1e82dad0ffa1 Portrait 8e2bc543-6ee2-45f9-bcd9-594b6ce84dcd Portrait Cinematic 4edb03c9-8a26-4041-9d01-f85b5d4abd71 Portrait Fashion 0d34f8e1-46d4-428f-8ddd-4b11811fa7c9 Pro B&W photography 22a9a7d2-2166-4d86-80ff-22e2643adbcf Pro Color Photography 7c3f932b-a572-47cb-9b9b-f20211e63b5b Pro Film Photography 581ba6d6-5aac-4492-bebe-54c424a0d46e Ray Traced b504f83c-3326-4947-82e1-7fe9e839ec0f Stock Photo 5bdc3f2a-1be6-4d1c-8e77-992a30824a2c Watercolor 1db308ce-c7ad-4d10-96fd-592fa6b75cc4
NoteA width and height of 0 and 0 will allow the output to try to match the input image reference.
- height - Height input resolution. Nano Banana only accept 0, 672, 768, 832, 864, 896, 1024, 1152, 1184, 1248, 1344. (default: 1024)
- width - Width input resolution. Nano Banana only accept 0, 768, 832, 864, 896, 1024, 1152, 1184, 1248, 1344, 1536. (default: 1024)
- guidances ā Object containing image references
- guidances.image_reference ā Array (max 6 items)
- References an existing image in Leonardo's system:
image:- id: UUID of the image (must already exist in Leonardo in their account)
- type : Where the image comes from:
"GENERATED"ā Image created by Leonardo AI"UPLOADāED"ā Image uploaded by user"INIT"ā Initial/seed image"GENERATION"ā From a generation
- strength (Required) Controls how much the reference image influences the output:
- "LOW" ā Subtle influence
- "MID" ā Medium influence
- "HIGH" ā Strong influence
- References an existing image in Leonardo's system:
NoteIf using the
seedparameter, the maximum seed number is2147483638.
Cost
The Nano Banana costs 26 API Credits per image.
Updated 4 days ago
