Home / Class/ _DefaultAsyncHttpxClient Class — anthropic-sdk-python Architecture

_DefaultAsyncHttpxClient Class — anthropic-sdk-python Architecture

Architecture documentation for the _DefaultAsyncHttpxClient class in _base_client.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  2afb17b6_1b58_e563_f8c1_9e9cf857849d["_DefaultAsyncHttpxClient"]
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"]
  2afb17b6_1b58_e563_f8c1_9e9cf857849d -->|defined in| 31e60ad8_cac8_652d_176d_4f7cf7dda1ad
  45d7d812_f42e_1579_8c9d_4e34e5e75d94["__init__()"]
  2afb17b6_1b58_e563_f8c1_9e9cf857849d -->|method| 45d7d812_f42e_1579_8c9d_4e34e5e75d94

Relationship Graph

Source Code

src/anthropic/_base_client.py lines 1453–1499

class _DefaultAsyncHttpxClient(httpx.AsyncClient):
    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)

Frequently Asked Questions

What is the _DefaultAsyncHttpxClient class?
_DefaultAsyncHttpxClient is a class in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is _DefaultAsyncHttpxClient defined?
_DefaultAsyncHttpxClient is defined in src/anthropic/_base_client.py at line 1453.

Analyze Your Own Codebase

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

Try Supermodel Free