2.x family of models:
gemini-2.0-flashis good for most use-cases.gemini-2.0-flash-liteis the most cost-effective model.gemini-2.5-pro-exp-03-25is the strongest multi-modal model.
Authentication
You can use Gemini models through either Google AI Studio or Google Cloud’s Vertex AI:Google AI Studio
Set theGOOGLE_API_KEY environment variable. You can get one from Google AI Studio.
Vertex AI
To use Vertex AI in Google Cloud:- Refer to the Vertex AI documentation to set up a project and development environment.
-
Install the
gcloudCLI and authenticate (refer to the quickstart for more details):
- Enable Vertex AI API and set the project ID environment variable (alternatively, you can set
project_idin theAgentconfig):
Example
UseGemini with your Agent:
View more examples here.
Grounding and Search
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:Parameters
Gemini is a subclass of the Model class and has access to the same params.