Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Anthropics Anthropic sdk python GCP Vertex Environment

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Cloud_Provider
Last Updated 2026-02-15 12:00 GMT

Overview

Google Cloud Vertex AI provider environment requiring google-auth and GCP credentials for accessing Claude models via Vertex AI.

Description

This environment extends the core SDK environment with Google Cloud-specific dependencies. It requires google-auth for GCP authentication. The Vertex client requires a region to be explicitly set (no default fallback) and optionally a GCP project ID. Authentication uses Google Application Default Credentials (ADC) or explicitly provided credentials.

Usage

Use this environment when deploying Claude models through Google Cloud Vertex AI instead of the direct Anthropic API. Required for the Cloud Provider Deployment workflow with Vertex AI as the target provider.

System Requirements

Category Requirement Notes
OS Linux, macOS, Windows Same as core SDK
Python >= 3.9 Same as core SDK
Network HTTPS outbound to Vertex AI endpoints Region-specific: {region}-aiplatform.googleapis.com
GCP Account Vertex AI API enabled Must enable Vertex AI in GCP console

Dependencies

Python Packages (Required)

Credentials

The following environment variables are used:

  • CLOUD_ML_REGION: Required. GCP region for Vertex AI (e.g., us-central1, europe-west4, or global).
  • ANTHROPIC_VERTEX_PROJECT_ID: GCP project ID. Can also be passed as parameter.
  • ANTHROPIC_VERTEX_BASE_URL: Override the Vertex AI endpoint URL.
  • Standard GCP Application Default Credentials (ADC) via GOOGLE_APPLICATION_CREDENTIALS or gcloud auth.

Quick Install

pip install 'anthropic[vertex]'

Code Evidence

Optional dependency declaration from pyproject.toml:43:

vertex = ["google-auth[requests] >=2, <3"]

Region requirement from vertex/_client.py:110-115:

if not is_given(region):
    region = os.environ.get("CLOUD_ML_REGION", NOT_GIVEN)
if not is_given(region):
    raise ValueError(
        "No region was given. The client should be instantiated with the `region` argument or the `CLOUD_ML_REGION` environment variable should be set."
    )

Project ID inference from vertex/_client.py:43-48:

@typed_cached_property
def project_id(self) -> str | None:
    project_id = os.environ.get("ANTHROPIC_VERTEX_PROJECT_ID")
    if project_id:
        return project_id
    return None

Base URL construction from vertex/_client.py:117-123:

if base_url is None:
    base_url = os.environ.get("ANTHROPIC_VERTEX_BASE_URL")
    if base_url is None:
        if region == "global":
            base_url = "https://aiplatform.googleapis.com/v1"
        else:
            base_url = f"https://{region}-aiplatform.googleapis.com/v1"

Common Errors

Error Message Cause Solution
MissingDependencyError: ... pip install anthropic[vertex] google-auth not installed Run pip install 'anthropic[vertex]'
ValueError: No region was given CLOUD_ML_REGION not set and no region parameter Set CLOUD_ML_REGION env var or pass region argument
AuthenticationError (401) Invalid or expired GCP credentials Run gcloud auth application-default login

Compatibility Notes

  • Region is mandatory: Unlike Bedrock, Vertex AI does not default to any region. You must explicitly set CLOUD_ML_REGION or pass region.
  • Global region: Setting region to "global" uses the global endpoint aiplatform.googleapis.com.
  • Project ID: Optional but recommended. If not set, uses the default project from ADC.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment