DEV Community

Cover image for Run Claude Code on Google Cloud: Use Your GCP Credits for AI Coding, Desktop Control, and More
Timothy Olaleke
Timothy Olaleke

Posted on

Run Claude Code on Google Cloud: Use Your GCP Credits for AI Coding, Desktop Control, and More

Run Claude Code on Google Cloud: Use Your GCP Credits for AI Coding, Desktop Control, and More

Claude Code runs natively on Google Cloud's Vertex AI. Same models, same capabilities (coding, agents, MCP servers, even desktop control) but billed entirely through your GCP account.

If you're already on Google Cloud, you don't need a separate Anthropic subscription. Your existing credits, billing, and IAM setup just work. Here's exactly how to set it up.

What You Get

This isn't a watered-down version. Through Vertex AI, you get:

  • All Claude models: Opus 4.6, Sonnet 4.6, Haiku 4.5, and previous generations
  • Full Claude Code features: file editing, code generation, terminal commands, MCP servers
  • Desktop control: screenshots, mouse clicks, keyboard input, browser automation
  • Your existing GCP billing: startup credits, free trial, enterprise spend, committed use discounts
Anthropic Direct Vertex AI
Billing Separate Anthropic account Your existing GCP billing
Credits Pay as you go Use GCP/startup credits
Auth API key management gcloud auth (already configured)
Compliance Separate vendor Same GCP governance
Models All Claude models All Claude models (same day availability)
Desktop Control Built-in (requires Pro/Max) Native macOS tools + MCP servers

Step 1: Enable Claude in the Model Garden

Go to Vertex AI Model Garden in your GCP console. Filter by Anthropic under Providers.

Google Cloud Console showing Vertex AI Model Garden filtered by Anthropic provider with 8 Claude models including Sonnet 4.6, Opus 4.6, Opus 4.5, and Haiku 4.5

You'll see 8 Claude models available:

  • Claude Opus 4.6: Most intelligent, industry leader for coding and agents
  • Claude Sonnet 4.6: Frontier intelligence for high volume coding and research
  • Claude Haiku 4.5: Fastest and most cost effective
  • Plus previous generations (Opus 4.5, 4.1, 4, Sonnet 4)

Click any model to see its details and model ID:

Claude Opus 4.6 detail page on Vertex AI showing model ID, Open in Vertex AI Studio button, 1M token input limit, and supported data types

Click "Open in Vertex AI Studio" to test the model directly in the console before setting up Claude Code.

Step 2: Configure Claude Code

Install Claude Code:

npm install -g @anthropic-ai/claude-code
Enter fullscreen mode Exit fullscreen mode

Add three environment variables to your ~/.zshrc or ~/.bashrc:

# Route Claude Code through Vertex AI
export CLAUDE_CODE_USE_VERTEX=1

# Your GCP project ID (find it at console.cloud.google.com)
export ANTHROPIC_VERTEX_PROJECT_ID=my-gcp-project

# Region (us-east5, europe-west1, or global)
export CLOUD_ML_REGION=us-east5
Enter fullscreen mode Exit fullscreen mode

That's it. No API keys to manage. Claude Code picks up your existing gcloud authentication automatically.

Make sure you're authenticated:

gcloud auth login
gcloud auth application-default login
Enter fullscreen mode Exit fullscreen mode

Want to use Opus instead of Sonnet (the default)?

export ANTHROPIC_MODEL=claude-opus-4-6
Enter fullscreen mode Exit fullscreen mode

Step 3: Run It

source ~/.zshrc
claude
Enter fullscreen mode Exit fullscreen mode

Everything works exactly the same: file editing, code generation, terminal commands, MCP servers. The only difference? Billing goes to your GCP account.

Step 4: Desktop Control on Vertex AI

Here's where it gets interesting. Claude Code's built-in computer use requires a claude.ai Pro/Max subscription. But on Vertex AI, you can get the same capabilities using native macOS tools:

# Take a screenshot (Claude Code is multimodal and can read images)
screencapture -x /tmp/screenshot.png

# Mouse and keyboard control
brew install cliclick

# Click at coordinates
cliclick c:500,300

# Type text
cliclick t:"Hello World"
Enter fullscreen mode Exit fullscreen mode

For browser automation, add an MCP server to ~/.claude/mcp.json:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["chrome-devtools-mcp@latest", "--autoConnect"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Now Claude Code can control Chrome, navigate pages, fill forms, and take screenshots. All running through Vertex AI on your GCP credits.

I used this exact setup to take the screenshots in this post. Claude Code navigated the GCP console, filtered the Model Garden by Anthropic, and captured everything automatically.

Pro Tips

Use the global Region

export CLOUD_ML_REGION=global
Enter fullscreen mode Exit fullscreen mode

The global endpoint gets the latest models first and avoids the 10% regional price premium on older model versions.

Switch Between Vertex and Direct

# Quick alias for direct Anthropic API when needed
cc() {
  CLAUDE_CODE_USE_VERTEX=0 claude "$@"
}
Enter fullscreen mode Exit fullscreen mode

Check Your Quotas

Vertex AI has per region quotas for Claude models:

Console > IAM & Admin > Quotas > Filter: "anthropic"
Enter fullscreen mode Exit fullscreen mode

If you hit rate limits, request a quota increase or switch regions.

TL;DR

What How
Enable Claude Model Garden > Anthropic > Click model
Configure CLAUDE_CODE_USE_VERTEX=1 + project ID + region
Auth gcloud auth login (you already did this)
Billing Your existing GCP credits
Desktop control screencapture + cliclick + MCP servers
Models All Claude models (Opus 4.6, Sonnet 4.6, Haiku 4.5)

If you're on GCP, your credits are sitting there. Use them.

Top comments (0)