AWS Bedrock with LangSpend (Python)

← Back to Docs

Track AWS Bedrock model costs with zero-code attribution in Python

Learn how to track AWS Bedrock model costs with LangSpend in Python. Works with Claude, Llama, and other Bedrock models.

Installation

Install required packages

Using pip:

terminal

Using uv:

terminal

Or install with Bedrock extras:

terminal

Basic Setup

Wrap your Bedrock client

setup.py

Claude on Bedrock

Claude 4 Sonnet Example with Customer & Feature Tracking

💡 Custom Metadata: Use the meta property in customer and feature dictionaries to pass any custom properties for advanced tracking and analytics.

bedrock-claude.py