Skip to main content
This guide shows you how to trace Amazon Bedrock model calls using LangSmith. Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models from leading AI companies via an API. By integrating LangSmith tracing, you can monitor, debug, and optimize your Bedrock applications with detailed observability into model interactions, latency, token usage, and custom metadata. LangSmith automatically captures traces when you use LangChain’s Bedrock integrations, providing insights into:
  • Request and response payloads
  • Token usage and costs
  • Latency and performance metrics
  • Custom tags and metadata for filtering and analysis
  • Multi-step chains and agent workflows

Installation

The Python integration requires langchain-aws, which provides the ChatBedrockConverse class for interacting with Bedrock models. The JavaScript integration requires @langchain/community for the Bedrock chat model, plus several AWS SDK packages for authentication, request signing, and streaming support.

Setup

To enable LangSmith tracing, configure your LangSmith API key and project settings. You’ll also need to set up your AWS credentials to authenticate with Bedrock.

LangSmith configuration

You can obtain your LangSmith API key from smith.langchain.com by navigating to Settings > API Keys. The LANGSMITH_PROJECT variable allows you to organize traces into different projects.

AWS credentials

Configure your AWS credentials to authenticate with Bedrock. You’ll need an AWS account with Bedrock access enabled. Follow the AWS setup instructions to create your credentials and enable model access:

Configure tracing

Once your environment variables are set, LangSmith will automatically trace all Bedrock model calls made through LangChain. You can enhance traces with custom tags and metadata to make filtering and analysis easier. Tags help you categorize traces (e.g., by environment, feature, or test type), while metadata allows you to attach arbitrary key-value pairs for detailed context. The following example shows you how to invoke a Bedrock model with tracing enabled and custom metadata attached:

View traces in LangSmith

After running your code, navigate to your LangSmith project at smith.langchain.com to view the traces. Each trace includes:
  • Request details: Input messages, model parameters, and configuration
  • Response details: Model output, token usage, and response metadata
  • Performance metrics: Latency, tokens per second, and cost estimates
  • Custom metadata: Tags and metadata you provided in the config parameter
You can filter traces by tags (e.g., aws-bedrock or integration-test), search by metadata fields, or drill into specific traces to debug issues.

Next steps


Connect these docs to Claude, VSCode, and more via MCP for real-time answers.