Use Claude on Vertex AI
Claude Inside Google Cloud
Google Cloud offers Claude through Vertex AI, which means model calls can run inside a Google Cloud project, under its billing, its identity controls, and its network policies. An organization that already builds on Google Cloud can add Claude without introducing a second provider's account. The SDK includes a Vertex client for this purpose, and it uses the same Messages API you have learned.
This lesson covers how the Vertex client is created, what a project and a region mean for each request, how authentication works through Google's standard credentials, and how to choose between the global endpoint and regional ones. It also includes a configuration check that catches the most common setup mistakes before the first call.
Project, Region, and Credentials
Three settings identify where a Vertex request runs:
| Setting | Meaning | Where it comes from |
|---|---|---|
project_id | The Google Cloud project that is billed and that owns the request | Your project's identifier |
region | Where the request is processed | Global, a multi-region group, or a specific region |
| Credentials | Who is making the request | Google's Application Default Credentials |
The project identifier is not the project's display name. It is the identifier Google assigns, which follows specific rules for characters and length. The region controls which endpoint receives the request, and the credentials decide which identity the request uses.
Installing the Vertex Client
As with Bedrock, the Vertex client is an extra of the SDK, because it depends on Google's authentication libraries:
python -m pip install -U "anthropic[vertex]"
Creating the Client
The client takes the project and the region. Authentication is not passed in the code, because the Google client libraries find the credentials in the environment:
from anthropic import AnthropicVertex
client = AnthropicVertex(project_id="my-project-id", region="global")
message = client.messages.create(
model="claude-opus-5",
max_tokens=256,
messages=[{"role": "user", "content": "Say hello."}],
)
Application Default Credentials are found in a fixed order: credentials set in the environment, the file that gcloud writes after a developer signs in, and the identity attached to the machine when it runs on Google Cloud. A deployed application normally uses the attached identity (Lesson 164), so no key file is needed.
Global Endpoints and Regions
The region setting selects one of three kinds of endpoint, and the choice affects where the request is processed and how much capacity is available:
| Setting | Meaning |
|---|---|
"global" | The global endpoint, which the documentation recommends |
"us" or "eu" | A multi-region group, which keeps processing within that geography |
A specific region, such as "us-east5" | Processing in one named region |
The documentation's recommendation for the global endpoint reflects that it can route requests to wherever capacity is available. A regional setting keeps processing in one place, which matters when data residency rules require it. Model availability also varies by region, so a region chosen for residency must be checked for the model it needs before the project relies on it.
Validating the Configuration
A Vertex configuration fails in predictable ways: a project identifier with uppercase letters, a region written in the wrong form, or a model identifier that the chosen region does not offer. The check below covers the first two, which are shape problems. The third requires the platform's model list, which the check cannot know.
"""vertex_config.py: check a Vertex project identifier and region before use."""
import re
PROJECT = re.compile(r"^[a-z][a-z0-9-]{4,28}[a-z0-9]$")
REGION = re.compile(r"^[a-z]+-[a-z]+\d+$")
GROUPS = {"global", "us", "eu"}
def check_vertex(project_id: str, region: str) -> list[str]:
problems = []
if not PROJECT.match(project_id):
problems.append(f"project id {project_id} does not follow Google Cloud's naming rules")
if region not in GROUPS and not REGION.match(region):
problems.append(f"region {region} is not global, us, eu, or a region name such as us-east5")
return problems
if __name__ == "__main__":
cases = [
("my-project-id", "global"),
("My_Project", "us-east5"),
("my-project-id", "us-east"),
]
for number, (project_id, region) in enumerate(cases, start=1):
print(f"case {number}:", check_vertex(project_id, region) or "ok")
Output:
case 1: ok
case 2: ["project id My_Project does not follow Google Cloud's naming rules"]
case 3: ['region us-east is not global, us, eu, or a region name such as us-east5']
How It Works
- The project pattern encodes Google's rules: a lowercase letter first, then lowercase letters, digits, or hyphens, and a final letter or digit, with a total length between six and thirty characters.
My_Projectfails on its uppercase letters and underscore. - Region groups are accepted directly.
global,us, andeuare checked by membership, so they never fall through to the pattern. - The region pattern expects a name with letters, a hyphen, and a number at the end.
us-east5matches, because it has the lettersus, the hyphen,east, and the number5.us-eastfails, because it ends in letters rather than a number. - Case two shows only the project problem. Its region is a valid name, so the check correctly reports nothing about it.
- The check is a shape test, not a list of real regions. Whether a project has access to a given region, or whether a model is offered there, is only known from the platform itself.
Summary
Claude on Vertex AI runs inside a Google Cloud project, identified by its project identifier, processed in a region chosen from the global endpoint, a multi-region group, or a single region, and authenticated through Application Default Credentials. The Vertex client is installed as an extra and created with the project and region. Configuration checks catch shape errors before any request is made, and they are most useful when they state exactly which rule each value broke. The next lesson covers the third platform, Microsoft Foundry.