Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Anthropics Anthropic sdk python Provider Selection And Dependencies

From Leeroopedia
Knowledge Sources
Domains Cloud_Deployment, LLM, Infrastructure
Last Updated 2026-02-15 00:00 GMT

Overview

The Anthropic Python SDK supports deploying Claude models across multiple cloud providers: AWS Bedrock, Google Cloud Vertex AI, and Azure AI Foundry. Rather than bundling all cloud provider dependencies into the core package, the SDK uses Python's optional dependency (extras) mechanism to allow users to install only the dependencies required for their chosen provider. This principle ensures minimal installation footprint while providing seamless multi-cloud support through a single unified SDK.

Optional Dependency Management for Multi-Cloud Support

The SDK's core package (anthropic) ships with a minimal set of dependencies: httpx, pydantic, typing-extensions, anyio, distro, sniffio, jiter, and docstring-parser. Cloud provider-specific libraries are declared as optional extras in pyproject.toml, following PEP 508 and PEP 621 conventions:

  • [bedrock] -- Pulls in boto3 and botocore for AWS authentication and request signing.
  • [vertex] -- Pulls in google-auth[requests] for Google Cloud OAuth2 token management.
  • Azure AI Foundry -- Requires no extra dependencies beyond the core SDK. Authentication is handled via API keys or user-supplied Azure AD token provider callables using the existing httpx transport.

This pattern has several advantages:

  1. Reduced attack surface -- Users only install the libraries they actually need. AWS users are never forced to install Google Cloud auth libraries and vice versa.
  2. Faster installation -- The base SDK installs quickly; provider extras add only the minimum required packages.
  3. Clear dependency boundaries -- Each extras group has explicit version constraints (e.g., boto3 >= 1.28.57, google-auth >= 2, < 3), preventing version conflicts with other parts of the user's stack.

Selecting the Right Cloud Provider

Choosing a cloud provider for Claude deployment depends on several factors:

AWS Bedrock

Best suited for organizations already invested in the AWS ecosystem. Bedrock integrates with IAM roles, VPC networking, and other AWS services. The SDK supports full AWS credential chain resolution (environment variables, profiles, session tokens, and implicit IAM role assumption via boto3.Session).

Google Cloud Vertex AI

Ideal for GCP-native environments. The SDK leverages Google's Application Default Credentials (ADC) and supports explicit access tokens or credential objects. It integrates with GCP's project and region model for resource management.

Azure AI Foundry

Suited for Azure-centric deployments. Authentication uses either a simple API key or an Azure Active Directory token provider callback. The Foundry client extends the base Anthropic client class directly, so it inherits all standard client features (including the models endpoint being explicitly disabled since it is not supported).

Design Rationale

The extras pattern ensures that the SDK remains a single package across all cloud providers. Users do not need to choose between separate packages (anthropic-bedrock, anthropic-vertex, etc.); instead, they install one package with the appropriate extras flag. This simplifies dependency management in requirements.txt, pyproject.toml, or Pipfile while preserving the ability to target multiple clouds from the same codebase by installing multiple extras simultaneously:

pip install anthropic[bedrock,vertex]

The SDK validates at runtime that the required provider dependencies are available, raising clear RuntimeError or ModuleNotFoundError messages when they are missing, guiding users to the correct installation command.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment