# @nilskluewer/pi-gcp-agent-platform

## Overview

Use Gemini models through Google Cloud Vertex AI / Gemini Enterprise Agent Platform in
[pi](https://github.com/earendil-works/pi).

The extension configures Google Application Default Credentials and the Vertex location
for Pi's built-in `google-vertex` provider. Pi's Google SDK then selects the matching
global, EU, US, or regional Vertex endpoint.

## Getting Started

```bash
pi install npm:@nilskluewer/pi-gcp-agent-platform
pi
/setup-gemini-vertexai your-project-id global
/model google-vertex/gemini-3.1-flash-lite
```

## Structure

```text
.
├── extensions/
│   └── gcp-agent-platform/
│       └── index.ts  # Pi extension entry point
├── LICENSE
├── README.md
└── package.json      # npm and Pi package manifest
```

## Setup

Requirements:

- Google Cloud project with the Vertex AI API enabled.
- Gemini models enabled/available in Vertex AI / Gemini Enterprise Agent Platform.
- `gcloud` CLI installed for Google Application Default Credentials.

Run the Pi setup command after installing the package:

```text
/setup-gemini-vertexai <google-cloud-project> [location]
```

Examples:

```text
/setup-gemini-vertexai my-project-id global
/setup-gemini-vertexai my-project-id eu
```

The command stores the project and location in Pi's user config directory and checks
Google Application Default Credentials. If credentials are missing in interactive mode,
it can run:

```bash
gcloud auth application-default login
```

Environment variables override the saved setup:

| Name | Description | Default |
|------|-------------|---------|
| `GOOGLE_CLOUD_PROJECT` | Google Cloud project ID used by Vertex AI. | Saved setup value |
| `GCLOUD_PROJECT` | Fallback project ID. | Optional |
| `GOOGLE_CLOUD_LOCATION` | Vertex AI region or multi-region. Use `global` for the global endpoint or `eu` for the EU multi-region endpoint. | Saved setup value or `eu` |
| `CLOUD_ML_REGION` | Compatibility fallback region. | Optional |
| `VERTEX_REGION` | Additional fallback region. | Optional |

Common endpoint mapping used by Vertex AI:

| Location | Endpoint |
|----------|----------|
| `global` | `https://aiplatform.googleapis.com` |
| `eu` | EU multi-region endpoint |
| `us` | US multi-region endpoint |
| other regions | Regional Vertex AI endpoint |

If the Anthropic Vertex package was configured first, this package reads that saved
project/location as a fallback so both packages can share the same Google auth setup.

## Run

Try the package without adding it to your settings:

```bash
pi -e npm:@nilskluewer/pi-gcp-agent-platform
```

Use any Gemini model exposed by Pi's built-in `google-vertex` model list and available
in your Vertex AI project, for example:

```bash
pi --provider google-vertex --model gemini-3.1-flash-lite
pi --provider google-vertex --model gemini-3.5-flash
```

## License

MIT
