Google Vertex AI Setup
Deploy Claude Code with Google Cloud's Vertex AI for enterprise-grade AI capabilities.
Prerequisites
Before setup, ensure you have:
- A GCP account with billing enabled
- A GCP project with Vertex AI API enabled
- Access to desired Claude models (e.g., Claude Sonnet 4.5)
- Google Cloud SDK (
gcloud) installed and configured - Quota allocated in your desired GCP region
Quick Setup
bash
# 1. Set your project
gcloud config set project YOUR-PROJECT-ID
# 2. Enable Vertex AI API
gcloud services enable aiplatform.googleapis.com
# 3. Configure Claude Code
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=global
export ANTHROPIC_VERTEX_PROJECT_ID=YOUR-PROJECT-IDStep-by-Step Setup
Step 1: Enable Vertex AI API
bash
# Set your project ID
gcloud config set project YOUR-PROJECT-ID
# Enable Vertex AI API
gcloud services enable aiplatform.googleapis.comStep 2: Request Model Access
- Navigate to the Vertex AI Model Garden in GCP Console
- Search for "Claude" models
- Request access to desired Claude models
- Wait for approval (may take 24-48 hours)
Step 3: Configure GCP Credentials
Claude Code uses standard Google Cloud authentication. Set environment variables:
| Variable | Purpose |
|---|---|
ANTHROPIC_VERTEX_PROJECT_ID | Your GCP project ID |
GCLOUD_PROJECT | Alternative project ID variable |
GOOGLE_CLOUD_PROJECT | Alternative project ID variable |
GOOGLE_APPLICATION_CREDENTIALS | Path to service account JSON |
Step 4: Configure Claude Code
bash
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=global
export ANTHROPIC_VERTEX_PROJECT_ID=YOUR-PROJECT-ID
export DISABLE_PROMPT_CACHING=1Step 5: Region Configuration
Override regions for specific models if needed:
bash
export VERTEX_REGION_CLAUDE_3_5_HAIKU=us-east5
export VERTEX_REGION_CLAUDE_3_5_SONNET=us-east5
export VERTEX_REGION_CLAUDE_3_7_SONNET=us-east5
export VERTEX_REGION_CLAUDE_4_0_OPUS=europe-west1
export VERTEX_REGION_CLAUDE_4_0_SONNET=us-east5Model Configuration
Default Models
| Type | Model ID |
|---|---|
| Primary | claude-sonnet-4-5@20250929 |
| Small/Fast | claude-haiku-4-5@20251001 |
Custom Models
bash
export ANTHROPIC_MODEL='claude-opus-4-1@20250805'
export ANTHROPIC_SMALL_FAST_MODEL='claude-haiku-4-5@20251001'IAM Configuration
Assign the roles/aiplatform.user role which includes:
aiplatform.endpoints.predict- Model invocation- Token counting permissions
1M Token Context Window
Claude Sonnet 4 and 4.5 support 1M token context on Vertex AI (beta).
Include the context-1m-2025-08-07 beta header in requests.
Troubleshooting
Quota Issues
- Check current quotas in Cloud Console
- Request increases through IAM & Admin > Quotas
Model Not Found (404)
- Confirm model is enabled in Model Garden
- Verify access to the specified region
429 Rate Limit Errors
- Ensure models are supported in your region
- Switch to
CLOUD_ML_REGION=global
Complete Configuration Example
bash
# ~/.bashrc or ~/.zshrc
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=global
export ANTHROPIC_VERTEX_PROJECT_ID=my-gcp-project
export DISABLE_PROMPT_CACHING=1
export ANTHROPIC_MODEL='claude-sonnet-4-5@20250929'
export ANTHROPIC_SMALL_FAST_MODEL='claude-haiku-4-5@20251001'Next Steps
- Amazon Bedrock Setup - AWS deployment option
- Model Configuration - Advanced model settings
- IAM Setup - Authentication configuration