Home / Function/ __init__() — anthropic-sdk-python Function Reference

__init__() — anthropic-sdk-python Function Reference

Architecture documentation for the __init__() function in _client.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  13292190_c332_c947_2781_45e82e05e90d["__init__()"]
  52b957ca_f6e2_8cc2_8b0b_1f00048d1b4f["AnthropicBedrock"]
  13292190_c332_c947_2781_45e82e05e90d -->|defined in| 52b957ca_f6e2_8cc2_8b0b_1f00048d1b4f
  898388b8_6a9d_318b_f831_38ab3b6ec302["_infer_region()"]
  13292190_c332_c947_2781_45e82e05e90d -->|calls| 898388b8_6a9d_318b_f831_38ab3b6ec302
  style 13292190_c332_c947_2781_45e82e05e90d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/lib/bedrock/_client.py lines 136–187

    def __init__(
        self,
        aws_secret_key: str | None = None,
        aws_access_key: str | None = None,
        aws_region: str | None = None,
        aws_profile: str | None = None,
        aws_session_token: str | 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,
        # Enable or disable schema validation for data returned by the API.
        # When enabled an error APIResponseValidationError is raised
        # if the API responds with invalid data for the expected schema.
        #
        # This parameter may be removed or changed in the future.
        # If you rely on this feature, please open a GitHub issue
        # outlining your use-case to help us decide if it should be
        # part of our public interface in the future.
        _strict_response_validation: bool = False,
    ) -> None:
        self.aws_secret_key = aws_secret_key

        self.aws_access_key = aws_access_key

        self.aws_region = _infer_region() if aws_region is None else aws_region
        self.aws_profile = aws_profile

        self.aws_session_token = aws_session_token

        if base_url is None:
            base_url = os.environ.get("ANTHROPIC_BEDROCK_BASE_URL")
        if base_url is None:
            base_url = f"https://bedrock-runtime.{self.aws_region}.amazonaws.com"

        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,
        )

        self.beta = Beta(self)
        self.messages = Messages(self)
        self.completions = Completions(self)

Subdomains

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/bedrock/_client.py.
Where is __init__() defined?
__init__() is defined in src/anthropic/lib/bedrock/_client.py at line 136.
What does __init__() call?
__init__() calls 1 function(s): _infer_region.

Analyze Your Own Codebase

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

Try Supermodel Free