Skip to main content
Gemini is a family of multimodal AI models by Google that can understand and generate text, images, audio, video, and code. See their model options here. Gemini stands out with native multimodal understanding across images, video, and audio, built-in Google Search for real-time information, File Search for RAG over your documents, native image generation and editing, text-to-speech synthesis, and advanced reasoning with thinking models.

Model Recommendations

Google has rate limits on their APIs. See the docs for more information.

Installation

Authentication

There are two ways to use the Gemini class: via Google AI Studio (using GOOGLE_API_KEY) or via Vertex AI (using Google Cloud credentials).

Google AI Studio

Set the GOOGLE_API_KEY environment variable. You can get one from Google AI Studio.

Vertex AI

To use Vertex AI in Google Cloud:
  1. Refer to the Vertex AI documentation to set up a project and development environment.
  2. Install the gcloud CLI and authenticate (refer to the quickstart for more details):
  1. Enable Vertex AI API and set the project ID environment variable (alternatively, you can set project_id in the Agent config):
Export the following variables:
Or configure directly in your agent:
Read more about Vertex AI setup here.

Example

Use Gemini with your Agent:
View more examples here.

Capabilities

Multimodal Input

Images, video, audio, PDFs

Image Generation

Generate and edit images

Grounding and Search

Real-time web grounding

File Search

Native RAG over documents

Speech Generation

Audio output responses

Thinking Models

Advanced reasoning

Multimodal Input

Gemini natively understands images, video, audio, and documents. See Google’s vision documentation for supported formats and limits.
See the following examples:

Image Generation

Generate and edit images using Gemini’s native image generation. See Google’s image generation documentation for more details.
Read more about image generation here. Gemini models support grounding and search capabilities that enable real-time web access. See more details in Google’s documentation. Enable web search by setting search=True:
For legacy models, use grounding=True instead:
Read more about search and grounding here. Search over your private knowledge base using Vertex AI. See Vertex AI Search documentation for setup details.

URL Context

Extract and analyze content from URLs. See Google’s URL context documentation for more details.
Read more about URL context here. Gemini’s File Search enables RAG over your documents with automatic chunking and retrieval. See Google’s File Search documentation for more details.

Speech Generation

Generate audio responses from the model. See Google’s speech generation documentation for available voices and options.

Context Caching

Cache large contexts to reduce costs and latency. See Google’s context caching documentation for more details.

Thinking Models

Gemini 2.5+ models support extended thinking for complex reasoning tasks. See Google’s thinking documentation for more details.
You can also use thinking_level for simpler control:
Read more about thinking models here.

Structured Outputs

Gemini supports native structured outputs using Pydantic models:
Read more about structured outputs here.

Tool Use

Gemini supports function calling to interact with external tools and APIs:
Read more about tool use here.

Params

Gemini is a subclass of the Model class and has access to the same params.