__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 8376fd1a_4cac_463e_0a29_9c402d41f70f["__init__()"] 0517492b_78c2_27e9_22ae_aae3b5f0e93e["Anthropic"] 8376fd1a_4cac_463e_0a29_9c402d41f70f -->|defined in| 0517492b_78c2_27e9_22ae_aae3b5f0e93e afc80c40_7ec9_e8a7_8063_f2ab74bc2ee7["get()"] 8376fd1a_4cac_463e_0a29_9c402d41f70f -->|calls| afc80c40_7ec9_e8a7_8063_f2ab74bc2ee7 style 8376fd1a_4cac_463e_0a29_9c402d41f70f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_client.py lines 62–116
def __init__(
self,
*,
api_key: str | None = None,
auth_token: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | 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.
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
# 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:
"""Construct a new synchronous Anthropic client instance.
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `ANTHROPIC_API_KEY`
- `auth_token` from `ANTHROPIC_AUTH_TOKEN`
"""
if api_key is None:
api_key = os.environ.get("ANTHROPIC_API_KEY")
self.api_key = api_key
if auth_token is None:
auth_token = os.environ.get("ANTHROPIC_AUTH_TOKEN")
self.auth_token = auth_token
if base_url is None:
base_url = os.environ.get("ANTHROPIC_BASE_URL")
if base_url is None:
base_url = f"https://api.anthropic.com"
super().__init__(
version=__version__,
base_url=base_url,
max_retries=max_retries,
timeout=timeout,
http_client=http_client,
custom_headers=default_headers,
custom_query=default_query,
_strict_response_validation=_strict_response_validation,
)
self._default_stream_cls = Stream
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_client.py.
Where is __init__() defined?
__init__() is defined in src/anthropic/_client.py at line 62.
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