Environment:Anthropics Anthropic sdk python Azure Foundry Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Cloud_Provider |
| Last Updated | 2026-02-15 12:00 GMT |
Overview
Azure AI Foundry provider environment requiring an API key or Azure AD token provider for accessing Claude models via Azure.
Description
This environment extends the core SDK environment with Azure-specific authentication. Unlike Bedrock and Vertex, it does not require additional Python packages beyond the core SDK. Authentication is via an API key or an Azure Active Directory token provider function. The resource name determines the base URL pattern: https://{resource}.services.ai.azure.com/anthropic/.
Usage
Use this environment when deploying Claude models through Azure AI Foundry instead of the direct Anthropic API. Required for the Cloud Provider Deployment workflow with Azure as the target provider.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Same as core SDK |
| Python | >= 3.9 | Same as core SDK |
| Network | HTTPS outbound to Azure Foundry endpoints | Pattern: {resource}.services.ai.azure.com
|
| Azure Account | Azure AI Foundry resource provisioned | Must have a Foundry resource with Claude model access |
Dependencies
Python Packages (Required)
- All core SDK dependencies (see Environment:Anthropics_Anthropic_sdk_python_Python_SDK_Core_Environment)
- No additional packages required (Azure auth is handled via API key or token provider callback)
Credentials
The following environment variables are used:
ANTHROPIC_FOUNDRY_API_KEY: Azure Foundry API key. One ofapi_keyorazure_ad_token_provideris required.ANTHROPIC_FOUNDRY_RESOURCE: Azure Foundry resource name (e.g.,example-resource).ANTHROPIC_FOUNDRY_BASE_URL: Override the Foundry endpoint URL. Mutually exclusive withresource.
Quick Install
# No extra installation needed beyond the core SDK
pip install anthropic
Code Evidence
Credential handling from foundry.py:146-153:
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."
)
Resource/base_url mutual exclusivity from foundry.py:155-162:
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")
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
AnthropicError: Missing credentials |
No API key or token provider given | Set ANTHROPIC_FOUNDRY_API_KEY or pass azure_ad_token_provider
|
ValueError: Must provide one of the base_url or resource arguments |
Neither resource nor base_url specified | Set ANTHROPIC_FOUNDRY_RESOURCE env var or pass resource parameter
|
ValueError: base_url and resource are mutually exclusive |
Both resource and base_url provided | Use only one: either resource or base_url
|
Compatibility Notes
- No extra packages: Unlike Bedrock (boto3) and Vertex (google-auth), Foundry needs no additional Python packages.
- Token provider: The
azure_ad_token_providerparameter accepts a callable that is invoked on every request, supporting token rotation. - Mutual exclusivity:
base_urlandresourcecannot both be specified.