AnthropicFoundry Class — anthropic-sdk-python Architecture
Architecture documentation for the AnthropicFoundry class in foundry.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 1ce2176e_cbf3_701e_e4dc_115c893fcace["AnthropicFoundry"] 0517492b_78c2_27e9_22ae_aae3b5f0e93e["Anthropic"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|extends| 0517492b_78c2_27e9_22ae_aae3b5f0e93e 28707db8_9678_34e5_eb77_ee47156aa183["foundry.py"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|defined in| 28707db8_9678_34e5_eb77_ee47156aa183 41f85833_2886_82e5_0cfb_ce00300efbf4["__init__()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| 41f85833_2886_82e5_0cfb_ce00300efbf4 21f11c19_4974_85b5_5a24_390833b3d4fd["models()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| 21f11c19_4974_85b5_5a24_390833b3d4fd 76a18e18_1479_6372_4145_29c953e80a58["messages()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| 76a18e18_1479_6372_4145_29c953e80a58 c43e293f_e599_a88d_f5be_16c0d71401dc["beta()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| c43e293f_e599_a88d_f5be_16c0d71401dc b88e2fc1_7080_57ed_a433_14a6f7486030["copy()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| b88e2fc1_7080_57ed_a433_14a6f7486030 1d13db30_ba0e_56d4_6555_7a3db10b4ac2["_get_azure_ad_token()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| 1d13db30_ba0e_56d4_6555_7a3db10b4ac2 c229995a_1a64_24ac_1990_cfdf81e8b762["_prepare_options()"] 1ce2176e_cbf3_701e_e4dc_115c893fcace -->|method| c229995a_1a64_24ac_1990_cfdf81e8b762
Relationship Graph
Source Code
src/anthropic/lib/foundry.py lines 90–264
class AnthropicFoundry(BaseFoundryClient[httpx.Client, Stream[Any]], Anthropic):
@overload
def __init__(
self,
*,
resource: str | None = None,
api_key: str | None = None,
azure_ad_token_provider: AzureADTokenProvider | 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.Client | None = None,
_strict_response_validation: bool = False,
) -> None: ...
@overload
def __init__(
self,
*,
base_url: str,
api_key: str | None = None,
azure_ad_token_provider: AzureADTokenProvider | 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.Client | None = None,
_strict_response_validation: bool = False,
) -> None: ...
def __init__(
self,
*,
resource: str | None = None,
api_key: str | None = None,
azure_ad_token_provider: AzureADTokenProvider | 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.Client | None = None,
_strict_response_validation: bool = False,
) -> None:
"""Construct a new synchronous 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 AnthropicFoundry class?
AnthropicFoundry is a class in the anthropic-sdk-python codebase, defined in src/anthropic/lib/foundry.py.
Where is AnthropicFoundry defined?
AnthropicFoundry is defined in src/anthropic/lib/foundry.py at line 90.
What does AnthropicFoundry extend?
AnthropicFoundry extends Anthropic.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free