> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-codex-docs-audit-20260719-0149.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini Image Generation

> Generate an image with GeminiTools, then save the returned image content to disk.

An Agent using the Gemini image generation tool.

```python gemini_image_generation.py theme={null}
"""Example: Using the GeminiTools Toolkit for Image Generation

An Agent using the Gemini image generation tool.

Example prompts to try:
- "Generate an image of a dog and tell me the color of the dog"
- "Create an image of a cat driving a car"

Run `uv pip install google-genai agno` to install the necessary dependencies.
"""

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()],
)

# ---------------------------------------------------------------------------
# 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

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno google-genai openai
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export GOOGLE_API_KEY="your_google_api_key_here"
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:GOOGLE_API_KEY="your_google_api_key_here"
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `gemini_image_generation.py`, then run:

    ```bash theme={null}
    python gemini_image_generation.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/models/gemini\_image\_generation.py](https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/91_tools/models/gemini_image_generation.py)
