Learn about configuring Claude Code through Google Cloud's Agent Platform, formerly Vertex AI, including setup, IAM configuration, and troubleshooting.
If you have Google Cloud credentials and want to start using Claude Code through Google Cloud's Agent Platform, the login wizard walks you through it. You complete the GCP-side prerequisites once per project; the wizard handles the Claude Code side.
Start Claude Code and choose Google Cloud's Agent Platform
Run claude. At the login prompt, select 3rd-party platform, then Google Vertex AI, the label the login prompt still uses for Google Cloud's Agent Platform.
3
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.
After you've signed in, run /setup-vertex any time to reopen the wizard and change your credentials, project, region, or model pins.
Region configuration
Claude Code supports Google Cloud's Agent Platform global, multi-region, and regional endpoints. Set CLOUD_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 Google Cloud's Agent Platform hostname for each form, including the aiplatform.eu.rep.googleapis.com and aiplatform.us.rep.googleapis.com hosts for multi-region locations.
Set up manually
To configure Google Cloud's Agent Platform through environment variables instead of the wizard, for example in CI or a scripted enterprise rollout, follow the steps below.
1. Enable Agent Platform API
Enable Google Cloud's Agent Platform API in your GCP project:
# Set your project ID
gcloud config set project YOUR-PROJECT-ID# Enable Agent Platform API
gcloud services enable aiplatform.googleapis.com
2. Request model access
Request access to Claude models in Google Cloud's Agent Platform:
Claude Code v2.1.121 or later supports X.509 certificate-based Workload Identity Federation through the same Application Default Credentials chain. Set GOOGLE_APPLICATION_CREDENTIALS to the path of your credential configuration file.
Advanced credential configuration
Claude Code supports automatic credential refresh for GCP through the gcpAuthRefresh 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.
The command's output is displayed to the user, but interactive input isn't supported. This works well for browser-based authentication flows where the CLI shows a URL and you complete authentication in the browser. The refresh command times out after three minutes if authentication does not complete. If you set 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:
# Enable Agent Platform integrationexport CLAUDE_CODE_USE_VERTEX=1export CLOUD_ML_REGION=global
export ANTHROPIC_VERTEX_PROJECT_ID=YOUR-PROJECT-ID# Optional: Override the Agent Platform endpoint URL for custom endpoints or gateways# export ANTHROPIC_VERTEX_BASE_URL=https://aiplatform.googleapis.com# Optional: Disable prompt caching if neededexport DISABLE_PROMPT_CACHING=1# Optional: Request 1-hour prompt cache TTL instead of the 5-minute defaultexport ENABLE_PROMPT_CACHING_1H=1# When CLOUD_ML_REGION=global, override region for models that don't support global endpointsexport VERTEX_REGION_CLAUDE_HAIKU_4_5=us-east5export VERTEX_REGION_CLAUDE_4_6_SONNET=europe-west1
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 Google Cloud's Agent Platform, the /logout command is unavailable since authentication is handled through Google Cloud credentials.
Claude Code disables MCP tool search by default on Google Cloud's Agent Platform, so MCP tool definitions load upfront. Google Cloud's Agent Platform 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 Google Cloud's Agent Platform 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 Google Cloud's Agent Platform model IDs.
Without these variables, the opus alias on Google Cloud's Agent Platform resolves to Opus 4.8 and the sonnet alias resolves to Sonnet 4.5. Set each variable to pin its alias to a specific version:
Claude Code uses these default models when no pinning variables are set:
Model type
Default value
Primary model
claude-opus-4-8
Small/fast model
Same as primary model
Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Google Cloud's Agent Platform, Claude Code defaults this to the primary model because Haiku may not be enabled in every project or region. To use Haiku for background tasks, set ANTHROPIC_DEFAULT_HAIKU_MODEL to a model ID that is available in your project.
When Claude Code starts with Google Cloud's Agent Platform 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:
The roles/aiplatform.user role includes the required permissions:
aiplatform.endpoints.predict - Required for model invocation and token counting
For more restrictive permissions, create a custom role with only the permissions above.
Claude Sonnet 5, Opus 4.6 and later, and Sonnet 4.6 support the 1M token context window on Google Cloud's Agent Platform. Sonnet 5 always runs with the 1M window, with no [1m] variant to select. For the other models, Claude Code automatically enables the extended context window when you select a 1M model variant.
Verify the model is available in the location you specified. Some models are offered only on global or multi-region locations such as eu and us, 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_MODEL or ANTHROPIC_DEFAULT_HAIKU_MODEL, or
Set a region or multi-region location using VERTEX_REGION_<MODEL_NAME> environment variables
If you encounter 429 errors:
For regional endpoints, ensure the primary model and small/fast model are supported in your selected region
Consider switching to CLOUD_ML_REGION=global for better availability
213Set these environment variables to specific Google Cloud's Agent Platform model IDs.213Set these environment variables to specific Google Cloud's Agent Platform model IDs.
214214
215Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Google Cloud's Agent Platform resolves to Opus 4.6.SetittotheOpus 4.8ID to usethelatestmodel:215Without these variables, the `opus` alias on Google Cloud's Agent Platform resolves to Opus 4.8andthe`sonnet`aliasresolvesto Sonnet 4.5.Seteach variable to pinitsaliasto a specific version:
229| Primary model | `claude-sonnet-4-5@20250929`|229| Primary model | `claude-opus-4-8`|
230| Small/fast model | Same as primary model |230| Small/fast model | Same as primary model |
231231
232Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Google Cloud's Agent Platform, Claude Code defaults this to the primary model because Haiku may not be enabled in every project or region. To use Haiku for background tasks, set `ANTHROPIC_DEFAULT_HAIKU_MODEL` to a model ID that is available in your project.232Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Google Cloud's Agent Platform, Claude Code defaults this to the primary model because Haiku may not be enabled in every project or region. To use Haiku for background tasks, set `ANTHROPIC_DEFAULT_HAIKU_MODEL` to a model ID that is available in your project.