Google Cloud also offers Claude through Google Cloud’s Agent Platform, formerly Vertex AI, which Google manages. If you use Agent Platform, follow Claude Code on Google Cloud’s Agent Platform instead. To find out which one you use, see Which offering are you using?
claude --version in your shell. To update, run claude update.
Prerequisites
- A Google Cloud project where the account setup is complete
- The
roles/claude.userIAM role on that project, for each Google account or service account that runs Claude Code - Your project ID and your workspace ID, which starts with
wrkspc_ - The gcloud CLI, if you sign in with a Google account rather than with a service account key file
Set up Claude Code
1
Create Application Default Credentials
- Google account
- Service account key file
Run this command in your shell, and sign in with the Google account that has the Run it even if you’ve already run
roles/claude.user role:gcloud auth login.If GOOGLE_APPLICATION_CREDENTIALS is set, unset it. While that variable is set, Claude Code uses the file it names and ignores the credentials that the command saves.2
Add the variables to your settings
Add three variables to the Use your own project ID and workspace ID in place of
env block of your user settings file, ~/.claude/settings.json. If the file doesn’t exist, create it with this content:my-project-id and the wrkspc_ value. To configure a single shell or a CI job instead, set the same three variables in that environment.You don’t need to log in to an Anthropic account, or to log out of one.3
Start Claude Code and check the provider
Run
claude in your shell, then run /status at the Claude Code prompt. The API provider line contains on Google Cloud, and the lines after it show your Workspace ID, GCP project, and GCP location. To print the same lines from your shell or a CI job, run claude auth status --text.If you see on Google Cloud, send a prompt, or run claude -p "hello" in a CI job. A reply confirms that your credentials and IAM role work. If you don’t see it, or Claude Code shows an error, troubleshoot the provider setup.Set up Claude Code for a team
Put theenv block from step 2 of Set up Claude Code in a managed settings file on each developer’s machine. Grant each developer the roles/claude.user role on the project, and have each one run gcloud auth application-default login on their own machine.
Pin model versions
If you deploy to a team, pin the model IDs, so a Claude Code update doesn’t move everyone to a newer model at once. Add these variables to theenv block that holds the three variables from Set up Claude Code:
Environment variables
Claude Code features that aren’t available
With Claude Models on Google Cloud (Anthropic managed), the features you can’t use include:- Fast mode: you can’t turn it on with
/fastor thefastModesetting - Remote Control and cloud sessions
- MCP connectors from claude.ai
- Channels
- The
/design-syncand/importcommands - Server-managed settings. To enforce settings for your team, use managed settings on each machine instead
Troubleshooting
If Claude Code asks you to log in, or theAPI provider line in /status doesn’t contain on Google Cloud:
- Make sure
CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUDis1 - Make sure
claude --versionprints 2.1.307 or later - Remove
CLAUDE_CODE_USE_BEDROCK,CLAUDE_CODE_USE_FOUNDRY, andCLAUDE_CODE_USE_ANTHROPIC_AWSfrom your shell and your settings files
CLAUDE_CODE_USE_VERTEX can stay set. After you change a variable, restart Claude Code. If /status doesn’t show the change, see A value you set is ignored.
No workspace ID found
Set ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID to your workspace ID, then restart Claude Code. Ignore the workspaceId constructor option that the message mentions: it’s for people who call Anthropic’s SDK from their own code.
No project was given
Set ANTHROPIC_GOOGLE_CLOUD_PROJECT to your Google Cloud project ID, then restart Claude Code.
Could not load Google Cloud credentials
Repeat step 1 of Set up Claude Code, with a new key if you use a service account key file.
Google Cloud credentials expired or invalid
If the message tells you to refresh your Google Cloud credentials, repeat step 1 of Set up Claude Code. With a service account key file, use a new key.
Google Cloud authentication failed
Follow the steps for Google Cloud credentials expired or invalid. If that doesn’t clear the error:
- Project: in
/status, make sure theGCP projectline names your project. If it names another project, or there’s no such line, followNo project was given - Workspace: in
/status, make sure theWorkspace IDline shows your workspace ID. If it shows another, followNo workspace ID found - IAM role: make sure the Google account or service account that runs Claude Code has
roles/claude.userorroles/claude.adminon the project in theGCP projectline. To grant the role, use the service’s grant command, or ask a project admin to grant it - Service: make sure the
claude.googleapis.comservice is enabled on the project in theGCP projectline. To enable it, follow the service’s account setup steps, or ask a project admin to enable it
Related resources
- Claude Models on Google Cloud (Anthropic managed): account setup, IAM roles, billing, data retention, and feature support
- Enterprise deployment overview: the other ways to deploy Claude Code, and proxy and gateway setup
- Model configuration: model aliases, pinning a model version, and restricting which models users can select