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

# Imagen Tool with OpenAI

## Code

```python cookbook/90_models/google/gemini/imagen_tool.py theme={null}
"""Example: Using the GeminiTools Toolkit for Image Generation

Make sure you have set the GOOGLE_API_KEY environment variable.
Example prompts to try:
- "Create a surreal painting of a floating city in the clouds at sunset"
- "Generate a photorealistic image of a cozy coffee shop interior"
- "Design a cute cartoon mascot for a tech startup, vector style"
- "Create an artistic portrait of a cyberpunk samurai in a rainy city"

"""

from pathlib import Path

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.models.gemini import GeminiTools

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[GeminiTools()],
)

response = agent.run(
    "Create an artistic portrait of a cyberpunk samurai in a rainy city",
)
if response and response.images and response.images[0].content:
    output_path = Path("tmp/cyberpunk_samurai.png")
    output_path.parent.mkdir(parents=True, exist_ok=True)
    output_path.write_bytes(response.images[0].content)
```

## Usage

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

  <Step title="Set your API keys">
    ```bash theme={null}
    export GOOGLE_API_KEY=xxx
    export OPENAI_API_KEY=xxx
    ```
  </Step>

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

  <Step title="Run Agent">
    ```bash theme={null}
    python cookbook/90_models/google/gemini/imagen_tool.py
    ```
  </Step>
</Steps>
