Code

cookbook/models/google/gemini/vertexai_search.py
from agno.agent import Agent
from agno.models.google import Gemini

# Replace with your actual Vertex AI Search datastore ID
datastore_id = "projects/your-project-id/locations/global/collections/default_collection/dataStores/your-datastore-id"

agent = Agent(
    model=Gemini(
        id="gemini-2.5-flash",
        vertexai_search=True,
        vertexai_search_datastore=datastore_id,
        vertexai=True,  # Use Vertex AI endpoint
    ),
    show_tool_calls=True,
    markdown=True,
)

agent.print_response("What are our company's policies regarding remote work?")

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Set up Vertex AI Search datastore

Create a Vertex AI Search datastore in Google Cloud Console and note the datastore ID.
3

Set environment variables

export GOOGLE_GENAI_USE_VERTEXAI="true"
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="your-location"
4

Install libraries

pip install -U google-genai agno
5

Update the datastore ID

Replace datastore_id in the code with your actual Vertex AI Search datastore ID.
6

Run Agent

python cookbook/models/google/gemini/vertexai_search.py

Information

  • Requires setting up a Vertex AI Search datastore in Google Cloud Console
  • Must use vertexai=True to enable Vertex AI endpoint
  • The datastore ID format: projects/{project_id}/locations/{location}/collections/default_collection/dataStores/{datastore_id}