> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.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.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")

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

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

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno google-genai
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeGroup>
      ```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"
      ```
    </CodeGroup>
  </Step>

  <Step title="Authenticate with Google Cloud">
    Sign in with Application Default Credentials:

    ```bash theme={null}
    gcloud auth application-default login
    ```
  </Step>

  <Step title="Run the example">
    Save the code above as `vertexai.py`, then run:

    ```bash theme={null}
    python vertexai.py
    ```
  </Step>
</Steps>

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