---
title: "Amazon Bedrock Agents Tracing"
description: Instrument LLM calls to AWS Bedrock via the boto3 client using the BedrockInstrumentor
---

import RegisterTracerPython from "../../../../snippets/register-tracer-python.mdx";

<Card horizontal icon="https://storage.googleapis.com/arize-phoenix-assets/assets/images/phoenix-docs-images/gc.ico" href="https://colab.research.google.com/github/Arize-ai/phoenix/blob/main/tutorials/integrations/amazon_bedrock_agents_tracing_and_evals.ipynb" title="Google Colab">
colab.research.google.com
</Card>

Amazon Bedrock Agents allow you to easily define, deploy, and manage agents on your AWS infrastructure. Traces on invocations of these agents can be captured using OpenInference and viewed in Phoenix.

This instrumentation will capture data on LLM calls, action group invocations (as tools), knowledgebase lookups, and more.

## Install

``` bash
pip install openinference-instrumentation-bedrock
```

## Setup

<RegisterTracerPython projectName="my-llm-app" />

After connecting to your Phoenix server, instrument `boto3` prior to initializing a `bedrock-runtime` client. All clients created after instrumentation will send traces on all calls to `invoke_model`, `invoke_agent`, and their streaming variations.

```python
import boto3

session = boto3.session.Session()
client = session.client("bedrock-runtime")
```

## Run Bedrock Agents

From here you can run Bedrock as normal

```python
session_id = f"default-session1_{int(time.time())}"

attributes = dict(
    inputText=input_text,
    agentId=AGENT_ID,
    agentAliasId=AGENT_ALIAS_ID,
    sessionId=session_id,
    enableTrace=True,
)
response = client.invoke_agent(**attributes)
```

## Observe

Now that you have tracing setup, all calls will be streamed to your running Phoenix for observability and evaluation.

<Frame caption="Bedrock Traces in Phoenix">
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/phoenix-docs-images/e2ec1f62-image.jpeg" />
</Frame>

## Resources

* [Tracing and Evals example](https://github.com/Arize-ai/phoenix/blob/main/tutorials/integrations/amazon_bedrock_agents_tracing_and_evals.ipynb)

* [OpenInference package](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-bedrock)


