---
slug: "twogiants-pi-anthropic-vertex"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/twoGiants/pi-anthropic-vertex@master/README.md"
repo: "https://github.com/twoGiants/pi-anthropic-vertex"
source_file: "README.md"
branch: "master"
---
# pi-anthropic-vertex

[![npm](https://img.shields.io/npm/v/@twogiants/pi-anthropic-vertex)](https://www.npmjs.com/package/@twogiants/pi-anthropic-vertex)

Anthropic Claude models on Google Cloud Vertex AI for [pi](https://github.com/earendil-works/pi).

> **Built-in support is coming.** There is an [open PR](https://github.com/earendil-works/pi/pull/5262)
> to add a native `anthropic-vertex` provider to pi, which would make this
> extension unnecessary. Multiple issues have requested this:
> [#5082](https://github.com/earendil-works/pi/issues/5082),
> [#5300](https://github.com/earendil-works/pi/issues/5300),
> [#4449](https://github.com/earendil-works/pi/issues/4449),
> [#1155](https://github.com/earendil-works/pi/issues/1155).
> If you want this to land, leave a 👍 on the [PR](https://github.com/earendil-works/pi/pull/5262).
> Until then, this extension is the only shipped solution.
>
> This extension started from a [comment on #1155](https://github.com/earendil-works/pi/issues/1155#issuecomment-4244554599).

## Compatibility

<!-- compat:start -->
| Extension | pi |
|-----------|-----|
| 0.1.12 | 0.80.10 |
| 0.1.11 | 0.80.3 |
| 0.1.10 | 0.80.0 - 0.80.2 |
| 0.1.9 | 0.78.0 - 0.79.4 |
| 0.1.8 | 0.75.5 - 0.78.0 |
| 0.1.7 | 0.75.4 |
| 0.1.6 | 0.75.1 |
| 0.1.5 | 0.74.1 |
| 0.1.4 | 0.72.0 - 0.73.1 |
| 0.1.3 | 0.72.0 - 0.73.0 |
| 0.1.2 | 0.67.1 - 0.71.0 |
| 0.1.0 | 0.66.1 |
<!-- compat:end -->

## Prerequisites

- Google Cloud project with Vertex AI API enabled
- Claude models enabled in [Model Garden](https://console.cloud.google.com/vertex-ai/model-garden)
- `gcloud` CLI installed and authenticated

## How it works

This extension injects an `AnthropicVertex` client into pi's built-in `anthropic-messages` streaming implementation. All message transformation, prompt caching, tool call normalization, thinking block replay, partial JSON streaming, and usage tracking are handled by pi's battle-tested internals, nothing is reimplemented.

Other Vertex AI extensions ([pi-vertex-claude](https://github.com/isaacraja/pi-vertex-claude), [pi-vertex](https://github.com/ssweens/pi-packages/tree/main/pi-vertex), [pi-anthropic-vertex](https://github.com/basnijholt/pi-anthropic-vertex)) reimplement the Anthropic streaming protocol from scratch at 500–1500 lines, losing features like prompt caching, tool call adjacency enforcement, aborted message filtering, and partial JSON parsing. This extension delegates to pi's built-in at ~160 lines and inherits everything for free.

Model definitions are pulled at runtime from pi's built-in Anthropic provider via `getModels("anthropic")`, so new Claude models are picked up automatically when pi updates.

## Install

```bash
pi install npm:@twogiants/pi-anthropic-vertex
```

Or install from git:

```bash
pi install git:github.com/twoGiants/pi-anthropic-vertex
```

## Setup

Authenticate with Google Cloud:

```bash
gcloud auth application-default login
```

Set your project and region:

```bash
export GOOGLE_CLOUD_PROJECT=your-project-id
export GOOGLE_CLOUD_LOCATION=us-east5  # optional, defaults to us-east5
```

## Usage

```bash
pi --provider anthropic-vertex --model claude-opus-4-6
pi --provider anthropic-vertex --model claude-sonnet-4-6
```

All Claude models available on Vertex AI are registered automatically.

## License

MIT
