Google Vertex AI in Practice

Using the AnthropicVertex Python SDK End to End

Anthropic ships an official Python client for Vertex AI. It looks almost exactly like the first-party client — the differences are all in how it authenticates and where the request goes.

Claude 3P 101 · Updated July 2026 · Unofficial guide

If your team already writes Python against the first-party Claude API, moving to Vertex AI is mostly a two-line change: swap the client class and drop the API key. Anthropic's anthropic package includes a dedicated AnthropicVertex client that signs requests with your Google Cloud identity and routes them to Vertex AI endpoints instead of Anthropic's. The Messages API surface — messages.create, streaming, tool use — stays the same.

Installation and setup

Anthropic's documentation recommends installing the Vertex extra alongside the Google Cloud SDK library:

pip install -U google-cloud-aiplatform "anthropic[vertex]"

Authentication uses Google Cloud Application Default Credentials (ADC) — the standard mechanism by which Google client libraries discover credentials from your environment rather than from hardcoded keys. On a developer machine, run gcloud auth application-default login once before making requests; in production, a service account attached to the workload fills the same role. There is no Anthropic API key anywhere in this flow. If ADC is unfamiliar, our ADC explainer covers it in depth.

You also need the prerequisites covered in the Model Garden setup guide: a project with billing enabled, the Vertex AI API turned on, and each Claude model enabled from its Model Garden card.

Creating the client and making a call

from anthropic import AnthropicVertex

client = AnthropicVertex(project_id="my-gcp-project", region="global")

message = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Summarize this contract clause..."}],
)
print(message.content)

Two constructor arguments do the platform-specific work. project_id is your Google Cloud project. region selects the endpoint type: "global" routes dynamically across regions for maximum availability, "us" or "eu" pins to a multi-region geography, and a specific value like "us-east1" or "europe-west1" guarantees a single region. Google's own samples use forms like AnthropicVertex(project_id=PROJECT_ID, region="us-east5"). Note that regional and multi-region endpoints carry a 10% pricing premium over global for Claude Sonnet 4.5 and later models — see the endpoint decision guide before pinning.

How it differs from the direct anthropic.Anthropic client

Aspectanthropic.Anthropic (1P)AnthropicVertex
AuthAnthropic API keyGoogle ADC (user or service account)
Request destinationAnthropic's APIVertex AI endpoints in your GCP project
Model in requestIn the request bodyIn the endpoint URL (the SDK places it for you)
API versionHTTP headeranthropic_version: "vertex-2023-10-16" in the body (SDK-handled)
Response IDsmsg_...msg_vrtx_... prefix

Under the hood, the wire format is nearly identical to the Anthropic Messages API with two documented differences: model is not passed in the request body (it goes in the endpoint URL), and anthropic_version is passed in the body — not as a header — and must be "vertex-2023-10-16". The SDK handles both, which is exactly why using it beats hand-rolling REST calls to the rawPredict endpoint. One visible tell that you're on Vertex: response message IDs carry a msg_vrtx_ prefix.

Model IDs are bare Anthropic-style names — claude-opus-4-8, claude-sonnet-5, claude-fable-5 — with no anthropic. prefix (that convention is Bedrock-only). Some older models take a date suffix, such as claude-haiku-4-5@20251001.

What carries over, what doesn't

Streaming works via client.messages.stream(...), and tool use, PDF input, prompt caching, token counting, and extended thinking are all supported on Vertex. Payloads are limited to 30 MB per request, with images capped at 5 MB each and 100 per request.

What you won't find on this client: Anthropic's Message Batches API, the Files API, and server-side tools such as code execution and web fetch are not available on Vertex AI (Google offers its own batch prediction mechanism instead — see the batch workaround guide). Requests that lean on those endpoints need restructuring, not just a client swap.

Where to go next

Walk through your first Claude call on Vertex AI if you're starting from zero, or jump to streaming responses and tool use for the next building blocks. The quickstart covers all four platforms side by side.

Sources