AsyncAnthropicFoundry Class — anthropic-sdk-python Architecture
Architecture documentation for the AsyncAnthropicFoundry class in foundry.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD ba122576_d069_c004_c1f5_107e86c806e6["AsyncAnthropicFoundry"] 0fd89929_7b38_b43a_7bae_43e09dda2e19["AsyncAnthropic"] ba122576_d069_c004_c1f5_107e86c806e6 -->|extends| 0fd89929_7b38_b43a_7bae_43e09dda2e19 28707db8_9678_34e5_eb77_ee47156aa183["foundry.py"] ba122576_d069_c004_c1f5_107e86c806e6 -->|defined in| 28707db8_9678_34e5_eb77_ee47156aa183 76c9fb78_6629_2ed5_0029_2d745559dbc9["__init__()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| 76c9fb78_6629_2ed5_0029_2d745559dbc9 74c99c6e_a489_4a3c_245f_b4bf54e1db6e["models()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| 74c99c6e_a489_4a3c_245f_b4bf54e1db6e c41b7e72_c407_f835_50b0_9f1c67066757["messages()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| c41b7e72_c407_f835_50b0_9f1c67066757 d79c65c4_0fc9_c846_153c_c2a5d19e16d6["beta()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| d79c65c4_0fc9_c846_153c_c2a5d19e16d6 d3b3784f_6eb4_9b89_67bf_1c44be1fabfb["copy()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| d3b3784f_6eb4_9b89_67bf_1c44be1fabfb 6b4d264c_08ec_fed6_7189_00072941c374["_get_azure_ad_token()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| 6b4d264c_08ec_fed6_7189_00072941c374 3c44a9b5_cb0f_61cb_1e6e_87ddd11b043e["_prepare_options()"] ba122576_d069_c004_c1f5_107e86c806e6 -->|method| 3c44a9b5_cb0f_61cb_1e6e_87ddd11b043e
Relationship Graph
Source Code
src/anthropic/lib/foundry.py lines 267–443
class AsyncAnthropicFoundry(BaseFoundryClient[httpx.AsyncClient, AsyncStream[Any]], AsyncAnthropic):
@overload
def __init__(
self,
*,
resource: str | None = None,
api_key: str | None = None,
azure_ad_token_provider: AsyncAzureADTokenProvider | 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,
http_client: httpx.AsyncClient | None = None,
_strict_response_validation: bool = False,
) -> None: ...
@overload
def __init__(
self,
*,
base_url: str,
api_key: str | None = None,
azure_ad_token_provider: AsyncAzureADTokenProvider | 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,
http_client: httpx.AsyncClient | None = None,
_strict_response_validation: bool = False,
) -> None: ...
def __init__(
self,
*,
resource: str | None = None,
api_key: str | None = None,
azure_ad_token_provider: AsyncAzureADTokenProvider | None = None,
base_url: str | 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,
http_client: httpx.AsyncClient | None = None,
_strict_response_validation: bool = False,
) -> None:
"""Construct a new asynchronous Anthropic Foundry client instance.
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `ANTHROPIC_FOUNDRY_API_KEY`
- `resource` from `ANTHROPIC_FOUNDRY_RESOURCE`
- `base_url` from `ANTHROPIC_FOUNDRY_BASE_URL`
Args:
resource: Your Foundry resource name, e.g. `example-resource` for `https://example-resource.services.ai.azure.com/anthropic/`
azure_ad_token_provider: A function that returns an Azure Active Directory token, will be invoked on every request.
"""
api_key = api_key if api_key is not None else os.environ.get("ANTHROPIC_FOUNDRY_API_KEY")
resource = resource if resource is not None else os.environ.get("ANTHROPIC_FOUNDRY_RESOURCE")
base_url = base_url if base_url is not None else os.environ.get("ANTHROPIC_FOUNDRY_BASE_URL")
if api_key is None and azure_ad_token_provider is None:
raise AnthropicError(
"Missing credentials. Please pass one of `api_key`, `azure_ad_token_provider`, or the `ANTHROPIC_FOUNDRY_API_KEY` environment variable."
)
if base_url is None:
if resource is None:
raise ValueError(
"Must provide one of the `base_url` or `resource` arguments, or the `ANTHROPIC_FOUNDRY_RESOURCE` environment variable"
)
base_url = f"https://{resource}.services.ai.azure.com/anthropic/"
elif resource is not None:
raise ValueError("base_url and resource are mutually exclusive")
super().__init__(
api_key=api_key,
base_url=base_url,
timeout=timeout,
max_retries=max_retries,
default_headers=default_headers,
default_query=default_query,
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the AsyncAnthropicFoundry class?
AsyncAnthropicFoundry is a class in the anthropic-sdk-python codebase, defined in src/anthropic/lib/foundry.py.
Where is AsyncAnthropicFoundry defined?
AsyncAnthropicFoundry is defined in src/anthropic/lib/foundry.py at line 267.
What does AsyncAnthropicFoundry extend?
AsyncAnthropicFoundry extends AsyncAnthropic.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free