Skip to main content
Use Google’s Gemini models through Google AI Studio or Google Cloud Vertex AI - platforms that provide access to large language models and other services. We recommend experimenting to find the best-suited model for your use case. Here are some general recommendations in the Gemini 2.x family of models:
  • gemini-2.0-flash is good for most use-cases.
  • gemini-2.0-flash-lite is the most cost-effective model.
  • gemini-2.5-pro-exp-03-25 is the strongest multi-modal model.
Refer to the Google AI Studio documentation and the Vertex AI documentation for information on available model versions.

Authentication

You can use Gemini models through either Google AI Studio or Google Cloud’s Vertex AI:

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 update your Agent configuration:
To use Vertex AI Search:

Example

Use Gemini with your Agent:
View more examples here.
Gemini models support grounding and search capabilities through optional parameters. This automatically sends tools for grounding or search to Gemini. See more details here. To enable these features, set the corresponding parameter when initializing the Gemini model: To use grounding:
To use search:
Combine URL context with Google Search to get a more in-depth analysis

Parameters

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