Loading

Set up Claude on Google Cloud (Anthropic managed)

Get a Google Cloud project ready for Claude Models on Google Cloud (Anthropic managed), give your own account access, and get a first reply from Claude in Python. Then run any Claude API sample by swapping its import and client.

25 minClaude Platform

Claude Models on Google Cloud (Anthropic managed) lets you call Claude through your own Google Cloud project. Anthropic operates the Claude API. Google Cloud handles access, so you sign in with your Google credentials. Once the project is set up and your account has access, a first reply takes a few lines of Python.

Check which service you have

Google Cloud offers Claude as two services, and each has its own setup. The steps here are for Anthropic managed. The other service is Google managed, where Google operates Claude models as part of Google Cloud's Agent Platform. To tell which service you have, find a value you already have in this table.

What you already haveAnthropic managedGoogle managed
The Python SDK client in your codeAnthropicGoogleCloudAnthropicVertex
The host in your request URLsclaude.googleapis.comAn Agent Platform host, such as aiplatform.googleapis.com
The Google Cloud consoleThe option labeled Anthropic managedClaude models in Model Garden

If your value is in the Google managed column, follow the Google managed guide instead.

What you need, and what it costs

You need these before you start:

You don't need an Anthropic API key, because this service doesn't use API keys.

Usage is billed, and the SDK client for this service is in beta. Billing goes through Google Cloud Marketplace, so the charges appear on your Google Cloud bill and Anthropic doesn't send a separate invoice. The one request you send here is billed too.

The commands below use placeholder values. Replace my-project-id with your project ID, you@example.com with your Google account, and wrkspc_01AbCdEf23GhIj with your workspace ID, which the next section explains.

Get the project ready, once

These steps create a new Anthropic organization for your Google Cloud project. It's separate from any Anthropic organization your company already has. The new organization starts with one workspace, the Default Workspace, and everyone who calls this service needs that workspace's ID.

An admin usually does this part. If yours already has, ask them for the workspace ID and go on to "Give yourself access".

Whoever does the steps needs:

  • Permission to purchase in Google Cloud Marketplace on your billing account.
  • Permission to enable services on the project.
  • An IAM role that lets you open the Claude Console, at platform.claude.com, which step 4 needs. Of the three predefined IAM roles, only roles/claude.admin on the project does.

Work through the steps in order.

  1. Subscribe in Marketplace. Open Google Cloud Marketplace and find the Claude Models on Google Cloud (Anthropic managed) listing. Click "Subscribe" and complete the purchase flow. Then return to the listing and click "Manage on Console", which opens the Claude page in the Google Cloud console.

  2. Enable two services on the project. Run this command:

    bash
    gcloud services enable claude.googleapis.com \
      anthropic-managed-claude.cloudpartnerservices.goog \
      --project=my-project-id

    claude.googleapis.com serves the API, and calls fail without it. The second is the Marketplace service that attributes the project's usage to your subscription.

  3. Activate the Anthropic organization. On the Claude page, click "Activate". In the Anthropic setup flow, enter a contact email address, then open the setup link sent to that address. Fill in the organization's name, entity type, country, and intended use. Then accept Anthropic's Commercial Terms of Service and Usage Policy.

  4. Copy the workspace ID. When the organization is active, the button on the Claude page changes to "Open Claude Console". Click it, then go to "Settings > Workspaces". The ID starts with wrkspc_. Pass it on to your developers.

The Marketplace subscription is made once, so to add another project, repeat these steps in that project, starting from step 2. If a step fails, see troubleshooting account setup.

Give yourself access

Each developer who calls Claude does these steps in their own terminal, in order.

  1. Set your project in gcloud.

    bash
    gcloud config set project my-project-id

    To see the project gcloud is using, run gcloud config get-value project.

  2. Grant your account roles/claude.user. The identity that makes the calls needs this role on the project.

    bash
    gcloud projects add-iam-policy-binding my-project-id \
      --member="user:you@example.com" \
      --role="roles/claude.user"

    You need permission to change the project's IAM policy to run this command. Without it, ask your admin to run the command for your account.

  3. Sign in with Application Default Credentials (ADC). The SDK client gets its Google access token from ADC. For local development, run this command:

    bash
    gcloud auth application-default login

    To check that ADC works, run gcloud auth application-default print-access-token.

  4. Set two environment variables. The SDK client needs your project ID and your workspace ID.

    bash
    export ANTHROPIC_GOOGLE_CLOUD_PROJECT="my-project-id"
    export ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID="wrkspc_01AbCdEf23GhIj"

Get a first reply

One request from Python shows that the whole setup works. Stay in the terminal where you set the two variables.

  1. Install the SDK with its Google Cloud extra.

    bash
    pip install -U "anthropic[google_cloud]"
  2. Save this file as first_reply.py. It creates the client, which resolves your Google credentials itself. Then it sends one request and prints what comes back.

    python
    from anthropic import AnthropicGoogleCloud
    
    client = AnthropicGoogleCloud()
    
    message = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=1024,
        messages=[{"role": "user", "content": "Hello, Claude"}],
    )
    print(message)
  3. Run the file.

    bash
    python first_reply.py

    Claude's reply prints in your terminal. If you get an error instead, go to the next section.

Check that the reply came through the project you meant. The client reads the project ID from ANTHROPIC_GOOGLE_CLOUD_PROJECT. Run echo "$ANTHROPIC_GOOGLE_CLOUD_PROJECT" in the same terminal. The value should be the ID of the project that you or your admin got ready. The project set in gcloud can be a different one, so check the variable.

To see the same request without the SDK, read the cURL sample.

If the first request fails

Two errors stop a first request: a permission error and a model that isn't available.

A permission error

Google Cloud returns an HTTP 403 error when the caller lacks permission. Check two things on the project you're calling:

  • claude.googleapis.com is enabled. Run gcloud services list --enabled --project=my-project-id and look for its name.
  • Your account has roles/claude.user or roles/claude.admin.

A new grant or a newly enabled service can take a moment to apply. If both checks pass, wait a moment and run first_reply.py again.

A model that isn't available

The error message reads Model {model} is not available for this organization's inference configuration. It comes back when you request a model that isn't available to your Anthropic organization. You can look up the models and their IDs, and Anthropic Support handles Claude itself, including models and API errors.

Run any Claude API sample

To run a Claude API sample on this service, replace its import and its client constructor. The model ID stays the same, because this service uses the same model IDs as the Claude API. A sample that uses a feature this service doesn't support won't run, so check the short list of features not supported first.

Say a sample written for the Claude API looks like this:

python
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(message)

After the swap, only the import and the client have changed:

python
from anthropic import AnthropicGoogleCloud

client = AnthropicGoogleCloud()

message = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(message)

The swap is enough because the new client takes care of what differs. A request to this service differs from a Claude API request in three ways.

What differsOn Anthropic managed
Base URLA project-scoped URL, in place of https://api.anthropic.com
AuthenticationAn Authorization: Bearer header with a Google access token. Don't send an x-api-key header.
WorkspaceThe workspace ID is part of the URL. Don't send an anthropic-workspace-id header.

The client builds the base URL from your project, location, and workspace ID, in this shape:

text
https://claude.googleapis.com/v1/projects/{project}/locations/global/workspaces/{workspace}/invoke

Where to go next

Take Claude Platform 101 next. It teaches what messages, max_tokens, and models are. Then take Tool use with the Messages API.

Whenever a sample, in these courses or in the docs, creates an anthropic.Anthropic() client, swap its import and client before you run it.

When you need them, these topics are in the docs: