> ## 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.

# Agent with Vertex AI

> Use Gemini through Vertex AI by setting environment variables or passing vertexai=True.

## Code

```python vertexai.py theme={null}
"""
To use Vertex AI, with the Gemini Model class, you need to set the following environment variables:

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

Or you can set the following parameters in the `Gemini` class:

gemini = Gemini(
    vertexai=True,
    project_id="your-google-cloud-project-id",
    location="your-google-cloud-location",
)
"""

from agno.agent import Agent, RunOutput  # noqa
from agno.models.google import Gemini

agent = Agent(model=Gemini(id="gemini-3.5-flash"), markdown=True)

# Get the response in a variable
# run: RunOutput = agent.run("Share a 2 sentence horror story")
# print(run.content)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")
```

## Usage

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

**1. Set up Vertex AI**

Set your environment variables:

```bash theme={null}
export GOOGLE_GENAI_USE_VERTEXAI="true"
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="your-location"
```

Or configure in code:

```python theme={null}
gemini = Gemini(
    vertexai=True,
    project_id="your-google-cloud-project-id",
    location="your-google-cloud-location",
)
```

**2. Install dependencies**

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

**3. Run Agent**

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

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


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