Documentation Index
Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before configuring Claude Code with Vertex AI, ensure you have:- A Google Cloud Platform (GCP) account with billing enabled
- A GCP project with Vertex AI API enabled
- Access to desired Claude models (for example, Claude Sonnet 4.6)
- Google Cloud SDK (
gcloud) installed and configured - Quota allocated in desired GCP region
Sign in with Vertex AI
If you have Google Cloud credentials and want to start using Claude Code through Vertex AI, the login wizard walks you through it. You complete the GCP-side prerequisites once per project; the wizard handles the Claude Code side.The Vertex AI setup wizard requires Claude Code v2.1.98 or later. Run
claude --version to check.Enable Claude models in your GCP project
Enable the Vertex AI API for your project, then request access to the Claude models you want in the Vertex AI Model Garden. See IAM configuration for the permissions your account needs.
Start Claude Code and choose Vertex AI
Run
claude. At the login prompt, select 3rd-party platform, then Google Vertex AI.Follow the wizard prompts
Choose how you authenticate to Google Cloud: Application Default Credentials from
gcloud, a service account key file, or credentials already in your environment. The wizard detects your project and region, verifies which Claude models your project can invoke, and lets you pin them. It saves the result to the env block of your user settings file, so you don’t need to export environment variables yourself./setup-vertex any time to reopen the wizard and change your credentials, project, region, or model pins.
Region configuration
Claude Code supports Vertex AI global, multi-region, and regional endpoints. SetCLOUD_ML_REGION to global, a multi-region location such as eu or us, or a specific region such as us-east5. Claude Code selects the correct Vertex AI hostname for each form, including the aiplatform.eu.rep.googleapis.com and aiplatform.us.rep.googleapis.com hosts for multi-region locations.
Vertex AI may not support the Claude Code default models on every endpoint type. Model availability varies across specific regions, multi-region locations, and global endpoints. You may need to switch to a supported location or specify a supported model.
Set up manually
To configure Vertex AI through environment variables instead of the wizard, for example in CI or a scripted enterprise rollout, follow the steps below.1. Enable Vertex AI API
Enable the Vertex AI API in your GCP project:2. Request model access
Request access to Claude models in Vertex AI:- Navigate to the Vertex AI Model Garden
- Search for “Claude” models
- Request access to desired Claude models (for example, Claude Sonnet 4.6)
- Wait for approval (may take 24-48 hours)
3. Configure GCP credentials
Claude Code uses standard Google Cloud authentication. For more information, see Google Cloud authentication documentation. Claude Code v2.1.121 or later supports X.509 certificate-based Workload Identity Federation through the same Application Default Credentials chain. SetGOOGLE_APPLICATION_CREDENTIALS to the path of your credential configuration file.
Claude Code uses
ANTHROPIC_VERTEX_PROJECT_ID as the project ID for Vertex AI requests. The GCLOUD_PROJECT and GOOGLE_CLOUD_PROJECT environment variables and the credential file referenced by GOOGLE_APPLICATION_CREDENTIALS take precedence over it. If none of these are set, the project ID is resolved from your gcloud configuration or the attached service account.Advanced credential configuration
Claude Code supports automatic credential refresh for GCP through thegcpAuthRefresh setting. When Claude Code detects that your GCP credentials are expired or cannot be loaded, it runs the configured command to obtain new credentials before retrying the request.
gcpAuthRefresh in project settings such as .claude/settings.json, the command runs only after you accept the workspace trust prompt.
4. Configure Claude Code
Set the following environment variables:VERTEX_REGION_CLAUDE_* variable. See the Environment variables reference for the full list. Check Vertex Model Garden to determine which models support global endpoints versus regional only.
Prompt caching is enabled automatically. To disable it, set DISABLE_PROMPT_CACHING=1. To request a 1-hour cache TTL instead of the 5-minute default, set ENABLE_PROMPT_CACHING_1H=1; cache writes with a 1-hour TTL are billed at a higher rate. For heightened rate limits, contact Google Cloud support. When using Vertex AI, the /login and /logout commands are disabled since authentication is handled through Google Cloud credentials.
Claude Code disables MCP tool search by default on Vertex AI, so MCP tool definitions load upfront. Vertex AI supports tool search for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Set ENABLE_TOOL_SEARCH=true to enable it on those models. Earlier models on Vertex AI do not accept the required beta header, and requests fail if you enable tool search with them.
5. Pin model versions
Set these environment variables to specific Vertex AI model IDs. WithoutANTHROPIC_DEFAULT_OPUS_MODEL, the opus alias on Vertex resolves to Opus 4.6. Set it to the Opus 4.7 ID to use the latest model:
| Model type | Default value |
|---|---|
| Primary model | claude-sonnet-4-5@20250929 |
| Small/fast model | Same as primary model |
ANTHROPIC_DEFAULT_HAIKU_MODEL to a model ID that is available in your project.
To customize models further:
Startup model checks
When Claude Code starts with Vertex AI configured, it verifies that the models it intends to use are accessible in your project. This check requires Claude Code v2.1.98 or later. If you have pinned a model version that is older than the current Claude Code default, and your project can invoke the newer version, Claude Code prompts you to update the pin. Accepting writes the new model ID to your user settings file and restarts Claude Code. Declining is remembered until the next default version change. If you have not pinned a model and the current default is unavailable in your project, Claude Code falls back to the previous version for the current session and shows a notice. The fallback is not persisted. Enable the newer model in Model Garden or pin a version to make the choice permanent.IAM configuration
Assign the required IAM permissions: Theroles/aiplatform.user role includes the required permissions:
aiplatform.endpoints.predict- Required for model invocation and token counting
Create a dedicated GCP project for Claude Code to simplify cost tracking and access control.
1M token context window
Claude Opus 4.7, Opus 4.6, and Sonnet 4.6 support the 1M token context window on Vertex AI. Claude Code automatically enables the extended context window when you select a 1M model variant. The setup wizard offers a 1M context option when it pins models. To enable it for a manually pinned model instead, append[1m] to the model ID. See Pin models for third-party deployments for details.
Troubleshooting
If you encounter “Could not load the default credentials” errors:- Run
gcloud auth application-default loginto set up Application Default Credentials - Set
GOOGLE_APPLICATION_CREDENTIALSto a service account key file path - See Configure GCP credentials for all options
- Check current quotas or request quota increase through Cloud Console
- Confirm model is Enabled in Model Garden
- Verify the model is available in the location you specified. Some models are offered only on
globalor multi-region locations such aseuandus, not in specific regions - If using
CLOUD_ML_REGION=global, check that your models support global endpoints in Model Garden under “Supported features”. For models that don’t support global endpoints, either:- Specify a supported model via
ANTHROPIC_MODELorANTHROPIC_DEFAULT_HAIKU_MODEL, or - Set a region or multi-region location using
VERTEX_REGION_<MODEL_NAME>environment variables
- Specify a supported model via
- For regional endpoints, ensure the primary model and small/fast model are supported in your selected region
- Consider switching to
CLOUD_ML_REGION=globalfor better availability