Home / File/ _client.py — anthropic-sdk-python Source File

_client.py — anthropic-sdk-python Source File

Architecture documentation for _client.py, a python file in the anthropic-sdk-python codebase. 21 imports, 1 dependents.

File python AnthropicClient SyncAPI 21 imports 1 dependents 2 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  7bcf2a66_49f2_0382_7180_1ee6501f1674["_client.py"]
  7af3d6da_76a3_56bc_2699_acdf9f99885d["7af3d6da:76a3:56bc:2699:acdf9f99885d"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 7af3d6da_76a3_56bc_2699_acdf9f99885d
  5fc3941b_5c44_ade1_4cda_60070b8f7508["_auth.py"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 5fc3941b_5c44_ade1_4cda_60070b8f7508
  064fa540_38f9_e315_bc1b_8783d8a1458a["load_auth"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 064fa540_38f9_e315_bc1b_8783d8a1458a
  6b910c1d_dcf8_e513_3a66_c1bcb9372ca3["refresh_auth"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 6b910c1d_dcf8_e513_3a66_c1bcb9372ca3
  c67615a5_6c22_f3a8_22e6_6badfeba0703["_beta.py"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> c67615a5_6c22_f3a8_22e6_6badfeba0703
  cd962377_5b75_72bb_f9a9_9885234ea412["Beta"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> cd962377_5b75_72bb_f9a9_9885234ea412
  3b272c1f_e14a_a9a2_ddda_e6af74125eaa["AsyncBeta"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 3b272c1f_e14a_a9a2_ddda_e6af74125eaa
  03096b6b_ec20_67a1_3f99_8e749f66e73a["_types"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 03096b6b_ec20_67a1_3f99_8e749f66e73a
  6af24006_2077_a1f4_15e9_47ba5fa99169["_utils"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 6af24006_2077_a1f4_15e9_47ba5fa99169
  7b9571c7_f3c7_9081_747d_05b632f1a3e2["_compat"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 7b9571c7_f3c7_9081_747d_05b632f1a3e2
  f5172907_31eb_109a_0598_9504abb61f15["_models"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> f5172907_31eb_109a_0598_9504abb61f15
  a638355f_94a2_d7f8_8bbf_f04aba6ea43f["_version"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> a638355f_94a2_d7f8_8bbf_f04aba6ea43f
  f21231fe_8062_9191_45ee_87b7ed54b10a["_streaming"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> f21231fe_8062_9191_45ee_87b7ed54b10a
  75c25a86_fda7_8038_d509_c06597656b74["_exceptions"]
  7bcf2a66_49f2_0382_7180_1ee6501f1674 --> 75c25a86_fda7_8038_d509_c06597656b74
  style 7bcf2a66_49f2_0382_7180_1ee6501f1674 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import os
from typing import TYPE_CHECKING, Any, Union, Mapping, TypeVar
from typing_extensions import Self, override

import httpx

from ... import _exceptions
from ._auth import load_auth, refresh_auth
from ._beta import Beta, AsyncBeta
from ..._types import NOT_GIVEN, NotGiven
from ..._utils import is_dict, asyncify, is_given
from ..._compat import model_copy, typed_cached_property
from ..._models import FinalRequestOptions
from ..._version import __version__
from ..._streaming import Stream, AsyncStream
from ..._exceptions import AnthropicError, APIStatusError
from ..._base_client import (
    DEFAULT_MAX_RETRIES,
    BaseClient,
    SyncAPIClient,
    AsyncAPIClient,
)
from ...resources.messages import Messages, AsyncMessages

if TYPE_CHECKING:
    from google.auth.credentials import Credentials as GoogleCredentials  # type: ignore


DEFAULT_VERSION = "vertex-2023-10-16"

_HttpxClientT = TypeVar("_HttpxClientT", bound=Union[httpx.Client, httpx.AsyncClient])
_DefaultStreamT = TypeVar("_DefaultStreamT", bound=Union[Stream[Any], AsyncStream[Any]])


class BaseVertexClient(BaseClient[_HttpxClientT, _DefaultStreamT]):
    @typed_cached_property
    def region(self) -> str:
        raise RuntimeError("region not set")

    @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

    @override
    def _make_status_error(
        self,
        err_msg: str,
        *,
        body: object,
        response: httpx.Response,
    ) -> APIStatusError:
        if response.status_code == 400:
            return _exceptions.BadRequestError(err_msg, response=response, body=body)

// ... (353 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does _client.py do?
_client.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in _client.py?
_client.py defines 2 function(s): _prepare_options, google.
What does _client.py depend on?
_client.py imports 21 module(s): 7af3d6da:76a3:56bc:2699:acdf9f99885d, AsyncBeta, Beta, _auth.py, _base_client, _beta.py, _compat, _exceptions, and 13 more.
What files import _client.py?
_client.py is imported by 1 file(s): __init__.py.
Where is _client.py in the architecture?
_client.py is located at src/anthropic/lib/vertex/_client.py (domain: AnthropicClient, subdomain: SyncAPI, directory: src/anthropic/lib/vertex).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free