Skip to main content
Available for: Python and TypeScript.
Wrap your BedrockRuntimeClient with wrapBedrock() (TypeScript) to trace all model invocations through the Bedrock Converse API — or patch boto3 with patch_bedrock() (Python).

Installation

Setup

In TypeScript, wrapBedrock() returns a wrapped client instance. In Python, patch_bedrock() patches botocore.client.ClientCreator.create_client — every boto3.client("bedrock-runtime", ...) instance created afterward has its converse() and converse_stream() methods traced automatically, with no wrapping step.

Example

Both wrapBedrock() and patch_bedrock() trace the Converse API (converse / converse_stream) only — the older, model-specific invoke_model / InvokeModelCommand API is not patched. Use converse() for traced calls.
converse_stream() (Python) and streaming Converse calls (TypeScript) are traced end-to-end in both languages, including time-to-first-token.

What gets captured

Token extraction requires the model response to include usage metadata. All Anthropic and Llama models on Bedrock return this via the Converse API. Check your model’s response schema if tokens show as zero.