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

__init__() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  45d7d812_f42e_1579_8c9d_4e34e5e75d94["__init__()"]
  2afb17b6_1b58_e563_f8c1_9e9cf857849d["_DefaultAsyncHttpxClient"]
  45d7d812_f42e_1579_8c9d_4e34e5e75d94 -->|defined in| 2afb17b6_1b58_e563_f8c1_9e9cf857849d
  afc80c40_7ec9_e8a7_8063_f2ab74bc2ee7["get()"]
  45d7d812_f42e_1579_8c9d_4e34e5e75d94 -->|calls| afc80c40_7ec9_e8a7_8063_f2ab74bc2ee7
  style 45d7d812_f42e_1579_8c9d_4e34e5e75d94 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_base_client.py lines 1454–1499

    def __init__(self, **kwargs: Any) -> None:
        kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
        kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
        kwargs.setdefault("follow_redirects", True)

        if "transport" not in kwargs:
            socket_options: List[Tuple[int, int, Union[int, bool]]] = [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, True)]

            TCP_KEEPINTVL = getattr(socket, "TCP_KEEPINTVL", None)

            if TCP_KEEPINTVL is not None:
                socket_options.append((socket.IPPROTO_TCP, TCP_KEEPINTVL, 60))
            elif sys.platform == "darwin":
                TCP_KEEPALIVE = getattr(socket, "TCP_KEEPALIVE", 0x10)
                socket_options.append((socket.IPPROTO_TCP, TCP_KEEPALIVE, 60))

            TCP_KEEPCNT = getattr(socket, "TCP_KEEPCNT", None)
            if TCP_KEEPCNT is not None:
                socket_options.append((socket.IPPROTO_TCP, TCP_KEEPCNT, 5))

            TCP_KEEPIDLE = getattr(socket, "TCP_KEEPIDLE", None)
            if TCP_KEEPIDLE is not None:
                socket_options.append((socket.IPPROTO_TCP, TCP_KEEPIDLE, 60))

            proxy_map = {key: None if url is None else Proxy(url=url) for key, url in get_environment_proxies().items()}

            transport_kwargs = {
                arg: kwargs[arg] for arg in ("verify", "cert", "trust_env", "http1", "http2", "limits") if arg in kwargs
            }

            transport_kwargs["socket_options"] = socket_options

            proxy_mounts = {
                key: None if proxy is None else AsyncHTTPTransport(proxy=proxy, **transport_kwargs)
                for key, proxy in proxy_map.items()
            }
            default_transport = AsyncHTTPTransport(**transport_kwargs)

            # Prioritize the mounts set by the user over the environment variables.
            proxy_mounts.update(kwargs.get("mounts", {}))
            kwargs["mounts"] = proxy_mounts

            # Sets the default transport so that HTTPX won't automatically configure proxies.
            kwargs["transport"] = default_transport

        super().__init__(**kwargs)

Subdomains

Calls

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is __init__() defined?
__init__() is defined in src/anthropic/_base_client.py at line 1454.
What does __init__() call?
__init__() calls 1 function(s): get.

Analyze Your Own Codebase

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

Try Supermodel Free