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

`GeminiTools` are a set of tools that allow an Agent to interact with Google AI API services for generating images and videos.

## Prerequisites

Before using `GeminiTools`, make sure to have the `google-genai` library installed and the credentials configured.

1. **Install dependencies:**
   ```bash theme={null}
   uv pip install google-genai agno
   ```

2. **Set your credentials:**
   * For Gemini API:
     ```bash theme={null}
     export GOOGLE_API_KEY="your-google-genai-api-key"
     ```
   * For Vertex AI:
     ```bash theme={null}
     export GOOGLE_CLOUD_PROJECT="your-google-cloud-project-id"
     export GOOGLE_CLOUD_LOCATION="your-google-cloud-location"
     export GOOGLE_GENAI_USE_VERTEXAI=true
     ```

## Initialization

Import `GeminiTools` and add it to your Agent's tool list.

```python theme={null}
from agno.agent import Agent
from agno.tools.models.gemini import GeminiTools

agent = Agent(
    tools=[GeminiTools()],
    )
```

## Usage Examples

GeminiTools can be used for a variety of tasks. Here are some examples:

### Image Generation

```python image_generation_agent.py theme={null}
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.models.gemini import GeminiTools
from agno.utils.media import save_base64_data

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.images:
    save_base64_data(response.images[0].content, "tmp/cyberpunk_samurai.png")
```

### Video Generation

<Note>
  Video generation requires Vertex AI.
</Note>

```python video_generation_agent.py theme={null}
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.models.gemini import GeminiTools
from agno.utils.media import save_base64_data

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

agent.print_response(
    "Generate a 5-second video of a kitten playing a piano",
)
response = agent.run("Generate a 5-second video of a kitten playing a piano")
if response.videos:
    for video in response.videos:
        save_base64_data(video.content, f"tmp/kitten_piano_{video.id}.mp4")
```

## Toolkit Params

| Parameter                | Type            | Default                     | Description                                                                                     |
| ------------------------ | --------------- | --------------------------- | ----------------------------------------------------------------------------------------------- |
| `api_key`                | `Optional[str]` | `None`                      | Google API key for authentication. If not provided, uses GOOGLE\_API\_KEY environment variable. |
| `vertexai`               | `bool`          | `False`                     | Whether to use Vertex AI instead of standard Gemini API. Required for video generation.         |
| `project_id`             | `Optional[str]` | `None`                      | Google Cloud project ID. Required when using Vertex AI.                                         |
| `location`               | `Optional[str]` | `None`                      | Google Cloud location/region. Required when using Vertex AI.                                    |
| `image_generation_model` | `str`           | `"imagen-3.0-generate-002"` | Model to use for image generation.                                                              |
| `video_generation_model` | `str`           | `"veo-2.0-generate-001"`    | Model to use for video generation.                                                              |
| `enable_generate_image`  | `bool`          | `True`                      | Enable the image generation function.                                                           |
| `enable_generate_video`  | `bool`          | `True`                      | Enable the video generation function.                                                           |
| `all`                    | `bool`          | `False`                     | Enable all available functions. When True, all enable flags are ignored.                        |

## Toolkit Functions

| Function         | Description                              |
| ---------------- | ---------------------------------------- |
| `generate_image` | Generate an image based on a text prompt |
| `generate_video` | Generate a video based on a text prompt  |

## Developer Resources

* View [Toolkit](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/models/gemini.py)
* View [Image Generation Guide](https://ai.google.dev/gemini-api/docs/image-generation)
* View [Video Generation Guide](https://ai.google.dev/gemini-api/docs/video)
