Claude Code on Google Vertex AI: Setup Steps and Common Errors

Blog / Developer tools

Claude Code on Google Vertex AI: Setup Steps and Common Errors

To run Claude Code through Google Vertex AI, set CLAUDE_CODE_USE_VERTEX=1, specify a Google Cloud project ID and a region, and sign in with gcloud to create Application Default Credentials (ADC). Requests are then billed and rate-limited against your GCP project, and you no longer sign in with a Claude account. The steps below follow the official documentation. Variable names and model identifiers change between versions, so check them against the official Anthropic and Google Cloud docs before you start.

What do you need before connecting?

The Vertex route depends on three things. If any one is missing, you will hit errors later:

  1. A Google Cloud project with billing enabled and the Vertex AI API turned on.
  2. Access to the Claude models, requested and granted in Vertex AI Model Garden. Approval varies by organization and region, so follow the official documentation. For the full process, see Calling Claude on Google Vertex AI: enabling access and authentication.
  3. IAM permission for your account or service account to call Vertex AI prediction. The official docs usually mention a role such as Vertex AI User; confirm against your organization's permission policy.

Claude models are available in a limited set of regions, and models do not map one-to-one to regions. Check the Model Garden page before you pick a region.

How do you set the environment variables and authenticate?

First, sign in to gcloud on your machine and create Application Default Credentials:

gcloud auth application-default login
gcloud config set project <your-project-id>

Then set the variables in your shell. These names come from the Vertex section of the Claude Code docs as of this writing (October 2026). Recheck them after upgrading:

export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=<region, or global if the official docs support it>
export ANTHROPIC_VERTEX_PROJECT_ID=<your-project-id>

To pin a specific model, also set ANTHROPIC_MODEL to the model identifier used on Vertex. Do not copy the model names from Anthropic's own API, because the naming formats differ. Copy the exact value from the model's page in Model Garden.

You can also put these variables in the env field of settings.json so you don't have to export them in every new terminal. For the layers and precedence rules, see Claude Code settings.json layers, precedence, and env configuration.

Once that's done, start claude in your project directory and send a simple prompt. If it returns normally, authentication, project, and region all work.

What if you get a quota error?

A typical symptom is a 429 response, or an error message containing words like "quota" or "resource exhausted". Go by the actual error text and the official docs. Check in this order:

  1. Open the quotas page in the Google Cloud console, filter for Vertex AI and the model in question, and look at the requests-per-minute and tokens-per-minute limits for your region. Default limits on new projects are usually low; the console shows the actual numbers.
  2. Make sure the region you configured is the region whose quota you are looking at. Quotas are counted separately per project, model, and region.
  3. A single Claude Code task sends many requests in a row, and the context is large. If your limits are low, reduce concurrency first (don't run several sessions at once), then consider requesting a quota increase in the console.
  4. If you keep getting 429s in a short window, wait and try again. Don't write a loop that retries aggressively.

To see where your usage actually goes, read How to estimate Claude Code token consumption.

What if the model isn't enabled, or you get a 404?

The typical symptoms are a 404, a not found message, or a notice that the project has no access to the publisher model. There are three common causes:

SymptomLikely causeFix
404, model or publisher not foundThe model identifier is wrong, or the model isn't available in that regionCopy the identifier from Model Garden and switch to a supported region
403, insufficient permissionsA missing IAM role, or ADC is signed in as the wrong accountRun gcloud auth list and gcloud config list to verify the account and project
Message says the API isn't enabled or access isn't grantedThe Vertex AI API is off, or the Claude access request wasn't approvedEnable the API, then resubmit the request and wait for model access to be granted

Also note that if ANTHROPIC_VERTEX_PROJECT_ID doesn't match the project gcloud is currently using, you can get errors that look like permission problems. Align the two first.

What if it can't connect or times out?

If it's neither of the errors above but a timeout or a failed handshake, the cause is usually at the network layer, for example a proxy that doesn't cover Google Cloud domains. Start with Troubleshooting Claude Code connection timeouts and errors: a four-layer network checklist. You can also use cdnping's IP and environment check to inspect your exit IP and DNS status, and the API status page to tell whether the problem is on the official API side or on your machine.

Is there another option if you don't have a GCP project?

Vertex suits teams that already use Google Cloud and need enterprise billing and permission management. If you simply want to use Claude Code from mainland China, and you have neither a GCP project nor an overseas credit card, look at the custom endpoint approach instead. Claude Code supports custom API endpoints; for setup, see Claude Code custom API setup, plus Codex and OpenCode endpoint configuration.

AGI Plan is a multi-provider LLM aggregation gateway. A single monthly subscription includes several capability groups, such as frontier reasoning, balanced general-purpose, flagship Chinese models, and fast lightweight models. Payment is in RMB and no overseas credit card is needed. Tools like Claude Code and Codex only need one endpoint address changed, and with Claude Code this approach does not require a Claude account. AGI Plan is a commercial partner of cdnping. To be clear, AGI Plan is not an officially authorized channel, and some models are available only outside China; see the models page for specifics. Whatever AI service you use, follow its terms of service and local laws. To get a feel for the setup flow first, see the beginner guide.

What should you do next?

  • You already have a GCP project: set the three variables above, sign in with ADC, and get it running. On a 429, check quotas first. On a 404, verify the model identifier and region.
  • You haven't enabled anything yet: finish the Model Garden access request first, then come back to configure.
  • You don't plan to use GCP: compare options in Claude Code subscription vs. API billing: how to choose, then decide on a billing method.

Related articles

Keep reading