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

get_platform() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient AsyncAPI calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  6a6f42c6_64f4_e757_be29_6b5c7161ee71["get_platform()"]
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"]
  6a6f42c6_64f4_e757_be29_6b5c7161ee71 -->|defined in| 31e60ad8_cac8_652d_176d_4f7cf7dda1ad
  9adda542_4e44_5534_7bf8_9b8d22a18ab9["platform_headers()"]
  9adda542_4e44_5534_7bf8_9b8d22a18ab9 -->|calls| 6a6f42c6_64f4_e757_be29_6b5c7161ee71
  771018a8_8f1d_ce6e_5fb8_d2878a9279e7["id()"]
  6a6f42c6_64f4_e757_be29_6b5c7161ee71 -->|calls| 771018a8_8f1d_ce6e_5fb8_d2878a9279e7
  style 6a6f42c6_64f4_e757_be29_6b5c7161ee71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_base_client.py lines 2152–2191

def get_platform() -> Platform:
    try:
        system = platform.system().lower()
        platform_name = platform.platform().lower()
    except Exception:
        return "Unknown"

    if "iphone" in platform_name or "ipad" in platform_name:
        # Tested using Python3IDE on an iPhone 11 and Pythonista on an iPad 7
        # system is Darwin and platform_name is a string like:
        # - Darwin-21.6.0-iPhone12,1-64bit
        # - Darwin-21.6.0-iPad7,11-64bit
        return "iOS"

    if system == "darwin":
        return "MacOS"

    if system == "windows":
        return "Windows"

    if "android" in platform_name:
        # Tested using Pydroid 3
        # system is Linux and platform_name is a string like 'Linux-5.10.81-android12-9-00001-geba40aecb3b7-ab8534902-aarch64-with-libc'
        return "Android"

    if system == "linux":
        # https://distro.readthedocs.io/en/latest/#distro.id
        distro_id = distro.id()
        if distro_id == "freebsd":
            return "FreeBSD"

        if distro_id == "openbsd":
            return "OpenBSD"

        return "Linux"

    if platform_name:
        return OtherPlatform(platform_name)

    return "Unknown"

Subdomains

Calls

Called By

Frequently Asked Questions

What does get_platform() do?
get_platform() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is get_platform() defined?
get_platform() is defined in src/anthropic/_base_client.py at line 2152.
What does get_platform() call?
get_platform() calls 1 function(s): id.
What calls get_platform()?
get_platform() is called by 1 function(s): platform_headers.

Analyze Your Own Codebase

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

Try Supermodel Free