@twogiants/pi-anthropic-vertex0.1.19
Anthropic Claude models on Google Cloud Vertex AI for pi
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-anthropic-vertex
Anthropic Claude models on Google Cloud Vertex AI for pi.
[!NOTE] Red Hat engineers: if you rely on this extension and it's broken and you need an urgent fix, reach out to me on Red Hat Slack. If I can't respond quickly, fork the repo, fix it yourself, and open a PR, I'll get to it eventually. Code must be clean and well understood. Vibe-coded PRs will be closed immediately.
Built-in support is coming. There is an open PR to add a native
anthropic-vertexprovider to pi, which would make this extension unnecessary. Multiple issues have requested this: #5082, #5300, #4449, #1155. If you want this to land, leave a 👍 on the PR. Until then, this extension is the only shipped solution.This extension started from a comment on #1155.
Compatibility
| Extension | pi |
|---|---|
| 0.1.19 | 1.3.0 |
| 0.1.18 | 0.99.1 - 0.99.2 |
| 0.1.17 | 0.86.1 - 0.87.1 |
| 0.1.16 | 0.85.1 - 0.86.1 |
| 0.1.15 | 0.85.1 |
| 0.1.14 | 0.85.1 |
| 0.1.13 | 0.81.1 - 0.82.0 |
| 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 |
Prerequisites
- Google Cloud project with Vertex AI API enabled
- Claude models enabled in Model Garden
gcloudCLI 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, usage tracking, and beta feature negotiation are handled by pi's battle-tested internals, nothing is reimplemented.
Other Vertex AI extensions (pi-vertex-claude, pi-vertex, 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 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
pi install npm:@twogiants/pi-anthropic-vertex
Or install from git:
pi install git:github.com/twoGiants/pi-anthropic-vertex
Setup
Authenticate with Google Cloud:
gcloud auth application-default login
Set your project using one of these methods:
Option 1: Environment variable
export GOOGLE_CLOUD_PROJECT=your-project-id
export GOOGLE_CLOUD_LOCATION=us-east5 # optional, defaults to us-east5
Also recognizes ANTHROPIC_VERTEX_PROJECT_ID, GOOGLE_CLOUD_PROJECT_ID, and CLOUD_ML_REGION for compatibility with existing Claude Code setups.
Option 2: Pi auth (recommended for PI WEB)
Use /login anthropic-vertex inside pi and enter your project ID, or configure ~/.pi/agent/auth.json directly:
{
"anthropic-vertex": {
"type": "api_key",
"key": "your-project-id",
"env": {
"GOOGLE_CLOUD_LOCATION": "us-east5"
}
}
}
This works in non-interactive environments like PI WEB where shell profile env vars may not be available.
Usage
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.
Contributing
This extension mirrors internal pi functions and must stay in sync with pi releases. See CONTRIBUTING.md for the full PR checklist.
License
MIT