Claude on Vertex AI: 5-Step Setup, Auth and Claude Code
Claude on Vertex AI means Anthropic's models served through Google Cloud. You enable the model in Model Garden, authenticate with Google's identity system (a service account or Application Default Credentials), and the bill lands on your Google Cloud project. You do not need a separate Anthropic API key. Setup takes five steps: prepare a project and billing, enable the Vertex AI API, enable Claude in Model Garden, configure authentication, then call the model or connect Claude Code.
This article follows that order. For available regions, model names, quota numbers and prices, the official Google Cloud documentation and your console are the source of truth, so this article lists no specific values.
How is calling Claude through Vertex AI different from the Anthropic API?
Decide whether this route fits you before you start.
| Anthropic API | Claude on Vertex AI | |
|---|---|---|
| Account system | Anthropic Console account and API key | Google Cloud project, IAM and service accounts |
| Billing | Anthropic invoice | Charged to your Google Cloud bill |
| Authentication | API key | OAuth token (ADC or service account) |
| Quota management | By Anthropic account tier | Managed per region and per model on the Google Cloud quotas page |
| Best for | Individuals, quick trials | Teams already on Google Cloud that want unified permissions and billing |
Note that Claude on Vertex is a service for Google Cloud customers. You need a working Google Cloud account and billing account, and Google has its own rules on payment methods and supported regions. If you do not meet the conditions, read the official guidance rather than looking for a workaround. Whether regions and features match the Anthropic API is also a question for the official documentation.
Step 1: Prepare the project, billing and permissions
- In the Google Cloud console, create or select a project and confirm it is linked to an active billing account.
- Enable the Vertex AI API. From the command line:
gcloud config set project YOUR_PROJECT_ID
gcloud services enable aiplatform.googleapis.com
- Grant the identity that will call the model a sufficient role. A common choice is Vertex AI User (
roles/aiplatform.user); check the IAM documentation for the exact minimum permissions.
Step 2: Enable Claude in Model Garden
- In the console, go to Vertex AI and open Model Garden.
- Search for Claude and pick the model card you need.
- Click enable on the model card and read and accept the terms. Some models may ask you to fill in details such as intended use first; follow what the page says.
- Once enabled, the page shows the regions and calling methods available for that model. Note the model ID and the region; you will need both in the next steps.
Do not write model IDs from memory; copy them from the model card. Model IDs on Vertex are not identical in format to those on the Anthropic API, and they usually carry a version suffix. Copying from the card is the safest approach.
Step 3: What if the quota is not enough?
If your first call returns a 429 or a quota error, check quotas first. Vertex calculates quotas per region and per model.
- On the console's quotas page (Quotas & System Limits under IAM & Admin; the menu name is whatever the console currently shows), filter for Vertex AI quotas and look at the current value and limit for your model.
- To get a higher limit, submit an adjustment request on the same page. Approval time and outcome are up to Google and are not guaranteed.
- If several regions are available, you can use different regions for different environments to spread the load, but confirm that the region actually offers the model you want.
Get a small-traffic call working first, then ask for more quota. That is easier than load testing from the start.
Step 4: How do you authenticate?
Vertex does not use API keys. There are two common approaches.
Local development: Application Default Credentials (ADC)
gcloud auth login
gcloud auth application-default login
The second command stores ADC on your machine, and both the SDK and Claude Code pick it up automatically.
Servers or CI: service accounts
- Create a service account and grant it the Vertex AI role mentioned above.
- Prefer the platform's workload identity (for example the service account attached to GKE or Cloud Run) so you do not have to keep a key file around.
- If you truly need a key file, point the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable at it, lock down the file permissions, and never commit it to a repository.
Step 5: Verify with the SDK
Anthropic's Python SDK includes a Vertex client. Install it with the vertex extra:
pip install "anthropic[vertex]"
from anthropic import AnthropicVertex
client = AnthropicVertex(
project_id="YOUR_PROJECT_ID",
region="YOUR_REGION", # use the region shown on the Model Garden page
)
msg = client.messages.create(
model="MODEL_ID_FROM_MODEL_GARDEN", # copy from the model card
max_tokens=256,
messages=[{"role": "user", "content": "用一句话介绍你自己"}],
)
print(msg.content[0].text)
If it returns text, your project, authorization, authentication, region and model ID all line up. For parameter details, see the official Anthropic and Google documentation.
How do you connect Claude Code to Vertex?
Claude Code can switch to Vertex through environment variables. The commonly used ones are:
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=YOUR_REGION
export ANTHROPIC_VERTEX_PROJECT_ID=YOUR_PROJECT_ID
After that, run claude on a machine where you have already done the ADC login. To pin a specific model, use the model environment variables described in the Claude Code documentation and enter the ID you copied from the model card in step 2. Variable names can change between versions, so follow the official Claude Code documentation.
You can also put these variables under env in settings.json; for layers and precedence, see Claude Code settings.json layers, precedence and env configuration. If a subscription login and other credentials exist at the same time, you may hit an auth conflict; see Claude Code auth conflict warning and 401 errors: how to fix them.
Common errors
| Symptom | Likely cause | What to check first |
|---|---|---|
| 403 / permission denied | The identity lacks a Vertex role, or the API is not enabled | IAM roles; whether aiplatform.googleapis.com is enabled |
| 404 / model not found | Wrong model ID, or the model is not offered in that region | Compare the ID and region against the model card |
| 429 / quota exceeded | Regional quota used up, or the default quota is low | Current usage and limit on the quotas page |
| Credentials not found | ADC login was not done, or the key path is wrong | gcloud auth application-default login, environment variables |
| Model not enabled | The project never accepted the terms in Model Garden | Re-check the enablement status under that project |
For the exact error text and status code meanings, rely on the Google Cloud documentation.
Slow or unstable connection: how do you tell where the problem is?
Latency and stability when reaching Google Cloud APIs from mainland China depend on your network path, and this article gives no fixed numbers. You can use the cdnping online speed test to watch first-connection and round-trip times from your network to various API providers, and check the probe history for the official API endpoint at /en/status/anthropic. For the reasoning and how to read the results, see AI API latency from China. Keep in mind that these are observations of public endpoints and do not necessarily reflect how Vertex regional endpoints behave. For whether Vertex is available, check the Google Cloud status page.
What if you have no Google Cloud account or overseas payment method?
The Vertex route assumes you can legitimately sign up for and pay for Google Cloud. If you cannot, compare the other routes:
- How to use the Claude API without an overseas credit card: payment options compared
- Using Claude through Amazon Bedrock: steps to enable model access
- How developers in China can use Claude: compliant options compared
Another option is a third-party aggregation gateway. AGI Plan is a commercial partner of cdnping and is a monthly-subscription gateway to multiple model providers, payable in RMB with no overseas credit card needed. To keep using Claude Code, Codex and similar tools you only change one endpoint URL, and a single subscription can switch between several capability groups. It is not an officially authorized channel, and some models are marked as available only outside China; see https://agiplan.dev/models for specifics. For setup steps, see https://agiplan.dev/startup. Before choosing a gateway, read Are third-party AI gateways reliable? Eight checks before you buy.
Summary and next steps
After the five steps, most problems turn out to be about permissions, region or model ID. Work through the table above item by item.
- You already have a Google Cloud project: run the full flow in a test project first, then move it into the team environment. On servers, prefer workload identity over key files.
- You just want Claude Code on your own machine: do the ADC login and set the three environment variables.
- You do not have a Google Cloud setup: pick a compliant route from the links above, or look at the setup flow at https://agiplan.dev/startup before deciding whether to subscribe.