← Catalog

pi-provider-vertex-anthropic

Pi agent extension for Claude models via Google Cloud Vertex AI

Extension

Install

Install with PiG

pig install npm:pi-provider-vertex-anthropic

Install with Pi

pi install npm:pi-provider-vertex-anthropic
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.3 (README.md). PiG does not review it.

pi-provider-vertex-anthropic

npm version license

A Pi provider plugin that gives you access to Claude models through Google Cloud Vertex AI. Use your existing GCP billing, stay within your organisation's cloud perimeter, and take advantage of regional deployments -- all from inside Pi.

Features

  • 10 Claude models from Opus 4.6 down to Haiku 3, including extended thinking
  • Streaming via Vertex AI's streamRawPredict endpoint with full SSE support
  • Prompt caching with automatic ephemeral cache control
  • Multiple auth strategies -- service account, Application Default Credentials, or the gcloud CLI
  • Interactive /login wizard that walks you through project, region, and API setup
  • Cross-tool env vars -- uses the same variables as Claude Code, with Opencode fallbacks

Prerequisites

  • A Google Cloud project with the Vertex AI API enabled
  • One of the following authentication methods:
    • Google Cloud CLI (gcloud) installed and authenticated
    • A service account key (via GOOGLE_APPLICATION_CREDENTIALS)
    • Application Default Credentials (gcloud auth application-default login)

Installation

Install using the Pi extension manager:

pi install npm:pi-provider-vertex-anthropic

The provider registers automatically and will be available the next time you start Pi.

Configuration

Interactive setup

Run /login inside Pi to walk through authentication, project selection, region selection, and API enablement in one step. Credentials are persisted to ~/.pi/agent/auth.json.

Environment variables

You can also configure the provider entirely through environment variables. The plugin checks them in the order shown below, picking the first one it finds.

Project ID

PriorityVariableUsed by
1ANTHROPIC_VERTEX_PROJECT_IDClaude Code
2GOOGLE_CLOUD_PROJECTOpencode, standard GCP tooling
3(persisted from /login)

Region

PriorityVariableUsed by
1CLOUD_ML_REGIONClaude Code
2VERTEX_LOCATIONOpencode
3VERTEXAI_LOCATIONOpencode (alternative)
4(persisted from /login)
5us-east5 (default)

Authentication

PriorityMethodDetails
1Service accountSet GOOGLE_APPLICATION_CREDENTIALS to your key file path
2Application Default CredentialsRun gcloud auth application-default login
3Google Cloud CLIRun gcloud auth login

[!TIP] For local development, gcloud auth login is the easiest way to get started. For CI or headless environments, use a service account key via GOOGLE_APPLICATION_CREDENTIALS.

Pi settings

To set a Vertex model as your default, add to ~/.pi/agent/settings.json:

{
  "packages": ["npm:pi-provider-vertex-anthropic"],
  "defaultProvider": "vertex-anthropic",
  "defaultModel": "claude-sonnet-4-5@20250929",
  "enabledModels": [
    "vertex-anthropic/claude-opus-4-6",
    "vertex-anthropic/claude-sonnet-4-5@20250929",
    "vertex-anthropic/claude-haiku-4-5@20251001"
  ]
}

Available models

ModelIDThinkingMax output
Claude Opus 4.6claude-opus-4-6Yes64k
Claude Opus 4.5claude-opus-4-5@20251101Yes64k
Claude Sonnet 4.5claude-sonnet-4-5@20250929Yes64k
Claude Haiku 4.5claude-haiku-4-5@20251001Yes64k
Claude 3.5 Sonnet v2claude-3-5-sonnet-v2@20241022No8k
Claude 3.5 Sonnetclaude-3-5-sonnet@20240620No8k
Claude 3.5 Haikuclaude-3-5-haiku@20241022No8k
Claude 3 Opusclaude-3-opus@20240229No4k
Claude 3 Sonnetclaude-3-sonnet@20240229No4k
Claude 3 Haikuclaude-3-haiku@20240307No4k

All models support 200k context, text + image input, and prompt caching.

Development

# Install dependencies
npm install

# Type-check
npm run typecheck

# Run tests
npm run test:run

# Watch mode
npm test

Project structure

src/
  index.ts          Extension entry point, provider registration, /login flow
  vertex-api.ts     SSE streaming against Vertex AI's streamRawPredict
  messages.ts       Message transformation and Anthropic API conversion
  auth.ts           Token acquisition (service account, ADC, gcloud CLI)
  config.ts         Environment variable resolution and endpoint building
  models.ts         Model definitions and provider constants
  pre-register.ts   Synchronous model ID collection for pre-registration
  shell.ts          Safe shell execution (spawn with args arrays)