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

> Authenticate Gemini against Vertex AI with environment variables or explicit `project_id` and `location` parameters on the Gemini model.

```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

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

agent = Agent(model=Gemini(id="gemini-3.7-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")

# ---------------------------------------------------------------------------
# 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"
export GOOGLE_GENAI_USE_VERTEXAI="true"
```

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

**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 `vertexai.py`, then run:

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

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


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