> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Nano Banana

**NanoBananaTools** enables an Agent to generate images using [Google's Gemini 2.5 Flash Image model](https://ai.google.dev/gemini-api/docs/image-generation) (Nano Banana).

## Prerequisites

You need to install the `google-genai` and `Pillow` libraries.

```shell theme={null}
uv pip install google-genai Pillow
```

Set the `GOOGLE_API_KEY` environment variable. You can obtain an API key from [Google AI Studio](https://aistudio.google.com/apikey).

```shell theme={null}
export GOOGLE_API_KEY=****
```

## Example

The following agent will use Nano Banana to generate an image based on a text prompt.

```python nano_banana_tools.py theme={null}
from pathlib import Path

from agno.agent import Agent
from agno.tools.nano_banana import NanoBananaTools

# Example 1: Basic NanoBanana agent with default settings
agent = Agent(tools=[NanoBananaTools()], name="NanoBanana Image Generator")

# Example 2: Custom aspect ratio generator
portrait_agent = Agent(
    tools=[
        NanoBananaTools(
            aspect_ratio="2:3"  # Portrait orientation
        )
    ],
    name="Portrait NanoBanana Generator",
)

# Example 3: Widescreen generator for panoramic images
widescreen_agent = Agent(
    tools=[
        NanoBananaTools(
            aspect_ratio="16:9"  # Widescreen format
        )
    ],
    name="Widescreen NanoBanana Generator",
)

# Test basic generation
agent.print_response(
    "Generate an image of a futuristic city with flying cars",
    markdown=True,
)

# Generate and save an image
response = widescreen_agent.run(
    "Create a panoramic nature scene with mountains and a lake at sunset",
    markdown=True,
)

# Save the generated image if available
if response.images and response.images[0].content:
    output_path = Path("generated_image.png")
    with open(output_path, "wb") as f:
        f.write(response.images[0].content)

    print(f"Image was successfully generated and saved to: {output_path}")
```

## Toolkit Params

| Parameter             | Type   | Default                    | Description                                                                                            |
| --------------------- | ------ | -------------------------- | ------------------------------------------------------------------------------------------------------ |
| `model`               | `str`  | `"gemini-2.5-flash-image"` | The Nano Banana model to use                                                                           |
| `aspect_ratio`        | `str`  | `"1:1"`                    | Image aspect ratio. Supported: `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9` |
| `api_key`             | `str`  | `None`                     | The Google API key for authentication                                                                  |
| `enable_create_image` | `bool` | `True`                     | Enable the create image functionality                                                                  |

## Toolkit Functions

| Function       | Description                               |
| -------------- | ----------------------------------------- |
| `create_image` | Generates an image based on a text prompt |

## Developer Resources

* View [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/nano_banana.py)
