Home / Function/ _infer_region() — anthropic-sdk-python Function Reference

_infer_region() — anthropic-sdk-python Function Reference

Architecture documentation for the _infer_region() function in _client.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  898388b8_6a9d_318b_f831_38ab3b6ec302["_infer_region()"]
  cbdd42fd_75f9_7cc6_3f3b_b8d939e4c157["_client.py"]
  898388b8_6a9d_318b_f831_38ab3b6ec302 -->|defined in| cbdd42fd_75f9_7cc6_3f3b_b8d939e4c157
  13292190_c332_c947_2781_45e82e05e90d["__init__()"]
  13292190_c332_c947_2781_45e82e05e90d -->|calls| 898388b8_6a9d_318b_f831_38ab3b6ec302
  86791f8b_40ce_c991_4689_7abd6c6ba63d["__init__()"]
  86791f8b_40ce_c991_4689_7abd6c6ba63d -->|calls| 898388b8_6a9d_318b_f831_38ab3b6ec302
  style 898388b8_6a9d_318b_f831_38ab3b6ec302 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/lib/bedrock/_client.py lines 70–90

def _infer_region() -> str:
    """
    Infer the AWS region from the environment variables or
    from the boto3 session if available.
    """
    aws_region = os.environ.get("AWS_REGION")
    if aws_region is None:
        try:
            import boto3

            session = boto3.Session()
            if session.region_name:
                aws_region = session.region_name
        except ImportError:
            pass

    if aws_region is None:
        log.warning("No AWS region specified, defaulting to us-east-1")
        aws_region = "us-east-1"  # fall back to legacy behavior

    return aws_region

Subdomains

Frequently Asked Questions

What does _infer_region() do?
_infer_region() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/bedrock/_client.py.
Where is _infer_region() defined?
_infer_region() is defined in src/anthropic/lib/bedrock/_client.py at line 70.
What calls _infer_region()?
_infer_region() is called by 2 function(s): __init__, __init__.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free