> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc-agui.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini Image Generation

> Use Gemini for generating images in Agno agents.

## Prerequisites

Install dependencies: `uv pip install google-genai agno`

```python theme={null}


import base64

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.models.gemini import GeminiTools
from agno.utils.media import save_base64_data

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[GeminiTools()],
    debug_mode=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    response = agent.run(
        "Generate an image of a dog and tell me the color of the dog",
    )

    if response and response.images:
        for image in response.images:
            if image.content:
                image_base64 = base64.b64encode(image.content).decode("utf-8")
                save_base64_data(
                    base64_data=image_base64,
                    output_path=f"tmp/dog_{image.id}.png",
                )
                print(f"Image saved to tmp/dog_{image.id}.png")
```

## Run the Example

```bash theme={null}
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools/models

# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate

python gemini_image_generation.py
```

For details, see [Gemini Image tools cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/models/gemini_image_generation.py).
