Metadata-Version: 2.3
Name: anthropic
Version: 1.14.0
Summary: The official Python library for the anthropic API
Project-URL: Homepage, https://github.com/anthropics/anthropic-sdk-python
Project-URL: Repository, https://github.com/anthropics/anthropic-sdk-python
Author-email: Anthropic <support@anthropic.com>
License: MIT
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: anyio<5,>=4.1.0
Requires-Dist: docstring-parser<1,>=0.15
Requires-Dist: httpx2<3,>=2.0.0
Requires-Dist: jiter<1,>=0.4.0
Requires-Dist: opentelemetry-api<2,>=1.1.0
Requires-Dist: pydantic<3,>=1.10.0
Requires-Dist: sniffio<2,>=1
Requires-Dist: typing-extensions<5,>=4.14
Provides-Extra: aiohttp
Requires-Dist: aiohttp<4,>=3.10.0; extra == 'aiohttp'
Provides-Extra: aws
Requires-Dist: boto3<2,>=1.28.57; extra == 'aws'
Requires-Dist: botocore<2,>=1.31.57; extra == 'aws'
Provides-Extra: bedrock
Requires-Dist: boto3<2,>=1.28.57; extra == 'bedrock'
Requires-Dist: botocore<2,>=1.31.57; extra == 'bedrock'
Provides-Extra: google-cloud
Requires-Dist: google-auth[requests]<3,>=2; extra == 'google-cloud'
Provides-Extra: mcp
Requires-Dist: mcp<3,>=1.0; (python_version >= '3.10') and extra == 'mcp'
Provides-Extra: vertex
Requires-Dist: google-auth[requests]<3,>=2; extra == 'vertex'
Provides-Extra: webhooks
Requires-Dist: standardwebhooks<2,>=1.0.1; extra == 'webhooks'
Description-Content-Type: text/markdown

# Claude SDK for Python

[![PyPI version](https://img.shields.io/pypi/v/anthropic.svg)](https://pypi.org/project/anthropic/)

The Claude SDK for Python provides access to the [Claude API](https://docs.anthropic.com/en/api/) from Python applications.

## Documentation

Tool helpers (`@beta_tool`, the tool runner and `ToolError`) are documented in [tools.md](https://github.com/anthropics/anthropic-sdk-python/tree/main/tools.md). The browser and computer toolset classes have their own guides, [browser-toolset.md](https://github.com/anthropics/anthropic-sdk-python/tree/main/browser-toolset.md) and [computer-toolset.md](https://github.com/anthropics/anthropic-sdk-python/tree/main/computer-toolset.md).

Full documentation is available at **[platform.claude.com/docs/en/api/sdks/python](https://platform.claude.com/docs/en/api/sdks/python)**.

## Installation

```sh
pip install anthropic
```

Upgrading from a `0.x` release? See the [v1 migration guide](https://github.com/anthropics/anthropic-sdk-python/tree/main/MIGRATION.md).

## Getting started

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)

message = client.messages.create(
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": "Hello, Claude",
        }
    ],

    model="claude-opus-5-5",
)

print(message.content)
```


## OpenTelemetry

The SDK reports each API call as an OpenTelemetry span when your application has registered a tracer provider.
It depends on `opentelemetry-api`, a required dependency, and never on an OpenTelemetry SDK.

```python
# a provider other than the registered one
client = Anthropic(open_telemetry={"tracer_provider": tracer_provider})
# no spans
quiet = Anthropic(open_telemetry=False)
# adds prompts and completions
verbose = Anthropic(open_telemetry={"traces": {"content_mode": "content"}})
# keeps the content of one span within this size
bounded = Anthropic(
    open_telemetry={"traces": {"content_mode": "content", "max_content_bytes": 65_536}}
)
# sends no trace context headers, for an application whose HTTP client instrumentation already sends them, so that
# a request does not carry them twice
unpropagated = Anthropic(open_telemetry={"propagation": False})

# sets gen_ai.conversation.id on the spans of one conversation's requests. with_options replaces the whole option,
# so start from client.open_telemetry, which has the client's
conversation = client.with_options(
    open_telemetry={**client.open_telemetry, "conversation_id": conversation_id}
)
conversation.messages.create(...)
```

A client that is given no `open_telemetry` option reads these environment variables when it is constructed: `ANTHROPIC_OPEN_TELEMETRY=false` turns its spans off, `ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE=content` adds prompts and completions, `ANTHROPIC_OPEN_TELEMETRY_TRACES_MAX_CONTENT_BYTES` sets `max_content_bytes`, and `ANTHROPIC_OPEN_TELEMETRY_PROPAGATION=false` sends no trace context headers.
A client that is given the option, even `{}` or a `tracer_provider` alone, reads none of them: what the option leaves out has its default (spans on, trace context headers sent, no prompts or completions, 750,000 bytes).
A copy made with `with_options` or `copy` keeps its client's option unless it is given its own.

## Requirements

Python 3.10+

## Contributing

See [CONTRIBUTING.md](https://github.com/anthropics/anthropic-sdk-python/tree/main/./CONTRIBUTING.md).

## License

This project is licensed under the MIT License. See the [LICENSE](https://github.com/anthropics/anthropic-sdk-python/tree/main/LICENSE) file for details.
