Skip to main content
Claude Models on Google Cloud (Anthropic managed) is the Claude API, run by Anthropic and reached through your Google Cloud project. To use it from Claude Code, sign in to Google Cloud and set three environment variables.
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?
Before you start, install Claude Code v2.1.307 or later. To check your version, run claude --version in your shell. To update, run claude update.

Prerequisites

  • A Google Cloud project where the account setup is complete
  • The roles/claude.user IAM 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

Run this command in your shell, and sign in with the Google account that has the roles/claude.user role:
Run it even if you’ve already run 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 env block of your user settings file, ~/.claude/settings.json. If the file doesn’t exist, create it with this content:
Use your own project ID and workspace ID in place of 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 the env 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 the env block that holds the three variables from Set up Claude Code:
Use the Claude API model IDs that you want from Models overview in place of the example values.

Environment variables

Claude Code features that aren’t available

With Claude Models on Google Cloud (Anthropic managed), the features you can’t use include: To see other features that are unavailable or partially supported, select the Google Cloud (Anthropic managed) tab in the feature availability summary.

Troubleshooting

If Claude Code asks you to log in, or the API provider line in /status doesn’t contain on Google Cloud:
  • Make sure CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD is 1
  • Make sure claude --version prints 2.1.307 or later
  • Remove CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_FOUNDRY, and CLAUDE_CODE_USE_ANTHROPIC_AWS from 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 the GCP project line names your project. If it names another project, or there’s no such line, follow No project was given
  • Workspace: in /status, make sure the Workspace ID line shows your workspace ID. If it shows another, follow No workspace ID found
  • IAM role: make sure the Google account or service account that runs Claude Code has roles/claude.user or roles/claude.admin on the project in the GCP project line. To grant the role, use the service’s grant command, or ask a project admin to grant it
  • Service: make sure the claude.googleapis.com service is enabled on the project in the GCP project line. To enable it, follow the service’s account setup steps, or ask a project admin to enable it