Metadata-Version: 2.4
Name: respan-instrumentation-anthropic
Version: 1.0.0
Summary: Respan instrumentation plugin for the Anthropic SDK
License: Apache 2.0
Author: Respan
Author-email: team@respan.ai
Requires-Python: >=3.11,<3.14
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: anthropic (>=0.39.0)
Requires-Dist: respan-tracing (>=2.3.0,<3.0.0)
Description-Content-Type: text/markdown

# respan-instrumentation-anthropic

Respan instrumentation plugin for the
[Anthropic Python SDK](https://github.com/anthropics/anthropic-sdk-python).

This package patches Anthropic client calls and emits spans using the
Respan/Traceloop GenAI attribute shape used across this repository.

## Install

```bash
pip install respan-instrumentation-anthropic
```

## Quickstart

```python
import os

from anthropic import Anthropic
from respan import Respan
from respan_instrumentation_anthropic import AnthropicInstrumentor

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    instrumentations=[AnthropicInstrumentor()],
)

client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

message = client.messages.create(
    model="claude-3-5-haiku-latest",
    max_tokens=128,
    messages=[{"role": "user", "content": "Write one line about tracing."}],
)

print(message.content)
respan.flush()
```

## Notes

- The instrumentor patches both `Anthropic` and `AsyncAnthropic`.
- `messages.create()` and streaming responses are traced.
- Managed agent session streaming is also captured when available through the Anthropic SDK.

