Metadata-Version: 2.4
Name: respan-instrumentation-aws-bedrock
Version: 0.1.0
Summary: Respan instrumentation plugin for AWS Bedrock Runtime
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: boto3 (>=1.34.0)
Requires-Dist: opentelemetry-semantic-conventions-ai (>=0.4.1)
Requires-Dist: respan-sdk (>=2.6.1)
Requires-Dist: respan-tracing (>=2.17.0,<3.0.0)
Description-Content-Type: text/markdown

# respan-instrumentation-aws-bedrock

Respan instrumentation plugin for AWS Bedrock Runtime calls made through
`boto3`.

## Installation

```bash
pip install respan-ai respan-instrumentation-aws-bedrock boto3
```

## Usage

```python
import json

import boto3
from respan import Respan
from respan_instrumentation_aws_bedrock import AWSBedrockInstrumentor

respan = Respan(instrumentations=[AWSBedrockInstrumentor()])
client = boto3.client("bedrock-runtime", region_name="us-east-1")

response = client.invoke_model(
    modelId="anthropic.claude-3-5-haiku-20241022-v1:0",
    body=json.dumps({
        "anthropic_version": "bedrock-2023-05-31",
        "max_tokens": 256,
        "messages": [{"role": "user", "content": "Say hello."}],
    }),
    contentType="application/json",
    accept="application/json",
)

body = json.loads(response["body"].read())
print(body["content"][0]["text"])
respan.flush()
```

The instrumentor patches `botocore.client.BaseClient._make_api_call` and only
emits spans for Bedrock Runtime operations. It currently normalizes
`InvokeModel`, `InvokeModelWithResponseStream`, `Converse`, and
`ConverseStream` into canonical Respan chat spans.

