AnthropicVertex Class — anthropic-sdk-python Architecture
Architecture documentation for the AnthropicVertex class in _client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 5fb2d3b6_3351_6580_364d_089a42b38b46["AnthropicVertex"] 4b46ed95_ff71_ea5d_7534_6929dc929bdb["SyncAPIClient"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|extends| 4b46ed95_ff71_ea5d_7534_6929dc929bdb f30eca5a_2fa0_68c1_64aa_b52331a2dcc8["NotGiven"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|extends| f30eca5a_2fa0_68c1_64aa_b52331a2dcc8 7bcf2a66_49f2_0382_7180_1ee6501f1674["_client.py"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|defined in| 7bcf2a66_49f2_0382_7180_1ee6501f1674 d29c8920_0fbf_b030_6f1b_87922ee2648a["__init__()"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|method| d29c8920_0fbf_b030_6f1b_87922ee2648a 57b2977f_9e9c_5e28_c40c_4a3bc9636498["_prepare_options()"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|method| 57b2977f_9e9c_5e28_c40c_4a3bc9636498 48e11fa3_882f_25cd_4edd_3ada19d59664["_prepare_request()"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|method| 48e11fa3_882f_25cd_4edd_3ada19d59664 26ddfdd3_edf1_2adc_5603_1eed5c624138["_ensure_access_token()"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|method| 26ddfdd3_edf1_2adc_5603_1eed5c624138 b236dbaf_763e_a93f_2228_184f29f8884a["copy()"] 5fb2d3b6_3351_6580_364d_089a42b38b46 -->|method| b236dbaf_763e_a93f_2228_184f29f8884a
Relationship Graph
Source Code
src/anthropic/lib/vertex/_client.py lines 90–232
class AnthropicVertex(BaseVertexClient[httpx.Client, Stream[Any]], SyncAPIClient):
messages: Messages
beta: Beta
def __init__(
self,
*,
region: str | NotGiven = NOT_GIVEN,
project_id: str | NotGiven = NOT_GIVEN,
access_token: str | None = None,
credentials: GoogleCredentials | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
http_client: httpx.Client | None = None,
_strict_response_validation: bool = False,
) -> None:
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."
)
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"
super().__init__(
version=__version__,
base_url=base_url,
timeout=timeout,
max_retries=max_retries,
custom_headers=default_headers,
custom_query=default_query,
http_client=http_client,
_strict_response_validation=_strict_response_validation,
)
if is_given(project_id):
self.project_id = project_id
self.region = region
self.access_token = access_token
self.credentials = credentials
self.messages = Messages(self)
self.beta = Beta(self)
@override
def _prepare_options(self, options: FinalRequestOptions) -> FinalRequestOptions:
return _prepare_options(options, project_id=self.project_id, region=self.region)
@override
def _prepare_request(self, request: httpx.Request) -> None:
if request.headers.get("Authorization"):
# already authenticated, nothing for us to do
return
request.headers["Authorization"] = f"Bearer {self._ensure_access_token()}"
def _ensure_access_token(self) -> str:
if self.access_token is not None:
return self.access_token
if not self.credentials:
self.credentials, project_id = load_auth(project_id=self.project_id)
if not self.project_id:
self.project_id = project_id
if self.credentials.expired or not self.credentials.token:
refresh_auth(self.credentials)
if not self.credentials.token:
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the AnthropicVertex class?
AnthropicVertex is a class in the anthropic-sdk-python codebase, defined in src/anthropic/lib/vertex/_client.py.
Where is AnthropicVertex defined?
AnthropicVertex is defined in src/anthropic/lib/vertex/_client.py at line 90.
What does AnthropicVertex extend?
AnthropicVertex extends SyncAPIClient, NotGiven.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free