Skip to content
,

How to Use Claude Code With Google Vertex AI (2026): Setup, Regions and Fixes

6–9 minutes
Woman in a lab coat in a co-working space with plants holding a tablet with a VERTEX AI card, hook Claude Code on Google Cloud

If your team runs on Google Cloud, you can bill Claude Code through your GCP project instead of an Anthropic account. Claude Code connects to Claude models on Google Cloud’s Agent Platform, the service Google renamed from Vertex AI. Your IAM roles, quotas and billing all stay in Google Cloud.

This guide covers the full setup. You will enable the API, request model access in Model Garden, sign in with the wizard or environment variables, choose a region, pin models, grant IAM, and fix the common errors.

It follows Anthropic’s Claude Code documentation as of December 2026. The settings still use the name “Vertex” (for example CLAUDE_CODE_USE_VERTEX), so you will see both names below.

TL;DR

  • Enable: gcloud services enable aiplatform.googleapis.com, then request Claude in Model Garden.
  • Wizard: run claude, choose 3rd-party platform → Google Vertex AI, or run /setup-vertex.
  • Manual: CLAUDE_CODE_USE_VERTEX=1, CLOUD_ML_REGION=global, ANTHROPIC_VERTEX_PROJECT_ID=your-project.
  • Credentials: gcloud auth application-default login or a service account key.
  • IAM: roles/aiplatform.user.
  • Defaults: Opus 5.5 primary, Sonnet 5.5 for background tasks. Pin models for teams.

Agent Platform vs Anthropic-Managed Google Cloud

There are now two ways to use Claude through a Google Cloud project:

Offering Managed by Covered here?
Google Cloud’s Agent Platform (formerly Vertex AI) Google Yes
Claude Models on Google Cloud Anthropic No, it has its own setup page

If you enabled Claude through Model Garden in the Vertex AI console, you are on Agent Platform and this guide applies. Not sure which AI Studio or Vertex product you use? Our Google AI Studio vs Vertex AI comparison explains the split.

Prerequisites

  • A GCP account with billing enabled
  • A project with the Agent Platform API enabled
  • Access to the Claude models you want
  • The gcloud CLI installed and signed in
  • Quota in your chosen region
  • Claude Code installed; see how to install Claude Code

Enable the API and Request Models

  1. Set your project and enable the API:
    gcloud config set project YOUR-PROJECT-ID
    gcloud services enable aiplatform.googleapis.com
  2. Open Model Garden in the Google Cloud console and search for “Claude”.
  3. Request access to each model you want, such as Claude Opus and Sonnet.
  4. Wait for approval. The docs say it may take 24 to 48 hours.

Tip from the docs: create a dedicated GCP project for Claude Code. It makes cost tracking and access control much simpler.

Quick Setup With the Wizard

  1. Run claude. At the login prompt, choose 3rd-party platform, then Google Vertex AI. The prompt still uses the old name. Already signed in? Run /login.
  2. Pick an auth method: Application Default Credentials from gcloud, a service account key file, or credentials already in your environment.
  3. Enter your project and region. The wizard checks which Claude models you can call.
  4. Pin models when offered, including 1M context.
  5. Done. Settings are saved to the env block of ~/.claude/settings.json.

Run /setup-vertex later to change credentials, project, region or pins.

Set Up Google Cloud Credentials

Claude Code uses standard Google Cloud authentication through Application Default Credentials (ADC).

  • Your own account: gcloud auth application-default login
  • Service account: set GOOGLE_APPLICATION_CREDENTIALS to the key file path.
  • Workload Identity Federation: X.509 certificate-based federation works through the same ADC chain. Point GOOGLE_APPLICATION_CREDENTIALS at the credential configuration file.

Claude Code always sends requests to the project in ANTHROPIC_VERTEX_PROJECT_ID, even if GOOGLE_CLOUD_PROJECT or your key file names a different project.

Auto-refresh expired credentials

{
  "gcpAuthRefresh": "gcloud auth application-default login",
  "env": { "ANTHROPIC_VERTEX_PROJECT_ID": "your-project-id" }
}

Claude Code checks that credentials really expired before running the command, shows its output, and times out after three minutes if you do not finish signing in.

Manual Setup With Environment Variables

For CI and scripted rollouts:

export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=global
export ANTHROPIC_VERTEX_PROJECT_ID=YOUR-PROJECT-ID
# optional: custom endpoint or gateway
# export ANTHROPIC_VERTEX_BASE_URL=https://aiplatform.googleapis.com

Prompt caching is on automatically. Set ENABLE_PROMPT_CACHING_1H=1 for a one-hour cache (billed at a higher write rate) or DISABLE_PROMPT_CACHING=1 to turn it off.

Keep these in a settings file rather than your shell profile; see the Claude Code settings guide. Our environment variables guide covers the rest.

Choose a Region

CLOUD_ML_REGION accepts three kinds of location:

Type Example Notes
Global endpoint global Best availability; not every model supports it
Multi-region us, eu Keeps data within a geography
Regional us-east5, europe-west1 Strict data location; check model availability

If a model does not support your chosen endpoint, override it per model with a VERTEX_REGION_CLAUDE_* variable, for example VERTEX_REGION_CLAUDE_HAIKU_4_5=us-east5. If CLOUD_ML_REGION is unset or malformed, Claude Code falls back to us-east5.

Pin Model Versions

Unpinned aliases follow Claude Code’s built-in defaults, which may not be enabled in your project. Pin before rolling out:

export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5@20251001'

Current defaults with no pins:

Role Default
Primary model claude-opus-5-5
Small/fast (background tasks) claude-sonnet-5-5

Agent Platform uses Sonnet for background tasks such as session titles because Haiku may not be enabled everywhere. Set ANTHROPIC_DEFAULT_HAIKU_MODEL to use Haiku instead.

Watch the cost: if you do not pin a primary model you pay Opus rates. To make Sonnet the default, set ANTHROPIC_MODEL to the full Sonnet ID. For switching models during a session, see how to change the model in Claude Code.

Fable models, Sonnet 5 and later, and Opus 4.7 and later get the 1M context window by default. Opus 4.6 and Sonnet 4.6 need a [1m] suffix. More in our context window guide.

At startup, Claude Code checks your pinned models. If a newer default is available it offers to update the pin, and if an unpinned default is missing it falls back to an earlier version. Admins can restrict choices with availableModels plus enforceAvailableModels in managed settings.

IAM and Cost Control

  • Grant roles/aiplatform.user. The key permission is aiplatform.endpoints.predict, used for model calls and token counting.
  • For least privilege, create a custom role with only that permission.
  • Use a dedicated project with budgets and alerts.
  • Raise rate limits through Google Cloud support.

Compare costs with a direct subscription in our Claude Code pricing guide. Running on AWS instead? See Claude Code on Amazon Bedrock.

Verify the Setup

Start Claude Code and run /status. You should see:

  • API provider: Google Vertex AI
  • GCP project: your project ID
  • Default region and Model: your region and resolved model

If the provider line is missing, the environment variables are not reaching Claude Code. Export them in the same shell or put them in the settings env block.

Troubleshooting

Could not load the default credentials

Run gcloud auth application-default login, or set GOOGLE_APPLICATION_CREDENTIALS to a service account key.

404 model not found

Confirm the model is enabled in Model Garden and offered in your location. Some models are only on global or multi-region endpoints. With global, check the model’s supported features, or set its VERTEX_REGION_CLAUDE_* variable.

429 errors

Make sure both the primary and background models are supported in your region, request more quota, or switch to CLOUD_ML_REGION=global.

Quota issues

Check and request quota increases in the Cloud Console quotas page.

“Switched to … because … is not available”

The model was disabled or is missing in your region. Run /model, highlight an available model and press s. Set CLAUDE_CODE_DISABLE_MODEL_ACCESS_FALLBACK=1 to fail instead of switching.

General issues are covered in Claude Code not working.

FAQ

Can Claude Code use Vertex AI?

Yes. Vertex AI is now called Google Cloud’s Agent Platform, and Claude Code supports it with CLAUDE_CODE_USE_VERTEX=1 or the /setup-vertex wizard.

Do I need an Anthropic account?

No. Billing and access go through your Google Cloud project.

Which region should I use?

global gives the best availability. Use us, eu or a specific region if you need data to stay in one location.

What IAM role does Claude Code need?

roles/aiplatform.user, or a custom role with aiplatform.endpoints.predict.

Why does /logout not work?

Authentication is handled by Google Cloud credentials, so /logout is unavailable on Agent Platform.

Which models are used by default?

Opus 5.5 as the primary model and Sonnet 5.5 for background tasks, unless you pin others.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a lab coat in a co-working space with plants holding a tablet with a VERTEX AI card, hook Claude Code on Google Cloud