Gemini
GeminiTools API reference and migration notes for its legacy Imagen and Veo defaults.
GeminiTools are a set of tools that allow an Agent to interact with Google AI API services for generating images and videos.
The default Imagen 3 and Veo 2 endpoints in this toolkit are retired. Google's March 24, 2026 Vertex AI notice lists their replacements and a June 30 migration deadline; the Gemini API lifecycle separately covers Imagen retirement. The examples below preserve the old integration and are not current hosted recipes.
For new image generation, use the Gemini image guide or OpenAITools. generate_image calls Google's generate_images API, so a Gemini-native image model cannot be substituted by changing only image_generation_model.
For video, Google's replacement is Veo 3.1. This wrapper exposes only a prompt and sends enhance_prompt=True; it does not expose duration or audio configuration. A migration must validate the current Veo API settings and media response with the selected SDK. Changing the model ID alone is not a verified migration.
Legacy Requirements
Before using GeminiTools, make sure to have the google-genai and openai libraries installed and the credentials configured.
-
Install dependencies:
uv pip install google-genai openai agno -
Set your credentials:
- For Gemini API:
export GOOGLE_API_KEY="your-google-genai-api-key" - For Vertex AI:
export GOOGLE_CLOUD_PROJECT="your-google-cloud-project-id" export GOOGLE_CLOUD_LOCATION="your-google-cloud-location" export GOOGLE_GENAI_USE_VERTEXAI=true
- For Gemini API:
The OpenAI agent examples additionally require OPENAI_API_KEY. Vertex project/location values do not authenticate requests: configure Application Default Credentials, enable the Vertex AI API, and grant the required model permissions in your project.
Legacy Initialization
Import GeminiTools and add it to your Agent's tool list.
from agno.agent import Agent
from agno.tools.models.gemini import GeminiTools
agent = Agent(
tools=[GeminiTools()],
)Legacy Usage Examples
These examples document the former Imagen 3 and Veo 2 calls:
Image Generation
import base64
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 and response.images[0].content:
image_base64 = base64.b64encode(response.images[0].content).decode("utf-8")
save_base64_data(image_base64, "tmp/cyberpunk_samurai.png")Video Generation
This toolkit's video path requires Vertex AI. The five-second request below belongs to the legacy Veo 2 example; the current Veo 3.1 model supports 4, 6, or 8 seconds, and this wrapper has no duration parameter.
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,
)
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 |