> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Vertex AI Search with Gemini

> Vertex AI Search allows Gemini to search through your data stores, providing grounded responses based on your private knowledge base.

```python vertex_ai_search.py theme={null}
"""Vertex AI Search with Gemini.

Vertex AI Search allows Gemini to search through your data stores,
providing grounded responses based on your private knowledge base.

Prerequisites:
1. Set up Vertex AI Search datastore in Google Cloud Console
2. Export environment variables:
   export GOOGLE_GENAI_USE_VERTEXAI="true"
   export GOOGLE_CLOUD_PROJECT="your-project-id"
   export GOOGLE_CLOUD_LOCATION="your-location"

Run `uv pip install google-generativeai` to install dependencies.
"""

from agno.agent import Agent
from agno.models.google import Gemini

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

# Replace with your actual Vertex AI Search datastore ID
# Format: "projects/{project_id}/locations/{location}/collections/default_collection/dataStores/{datastore_id}"
datastore_id = "projects/your-project-id/locations/global/collections/default_collection/dataStores/your-datastore-id"

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

# Ask questions that can be answered from your knowledge base
agent.print_response("What are our company's policies regarding remote work?")

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno google-genai
```

**2. Export environment variables**

```bash Mac/Linux theme={null}
export GOOGLE_CLOUD_LOCATION="your_google_cloud_location_here"
export GOOGLE_CLOUD_PROJECT="your_google_cloud_project_here"
```

```bash Windows theme={null}
$Env:GOOGLE_CLOUD_LOCATION="your_google_cloud_location_here"
$Env:GOOGLE_CLOUD_PROJECT="your_google_cloud_project_here"
```

**3. Authenticate with Google Cloud**

Sign in with Application Default Credentials:

```bash theme={null}
gcloud auth application-default login
```

**4. Run the example**

Save the code above as `vertex_ai_search.py`, then run:

```bash theme={null}
python vertex_ai_search.py
```

Full source: [cookbook/90\_models/google/gemini/vertex\_ai\_search.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/google/gemini/vertex_ai_search.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.