Skip to main content
PromptLayer can auto-instrument Amazon Bedrock Runtime calls made with Boto3 or AWS SDK v3 and export supported operations as OpenTelemetry spans. Each supported direct Bedrock call appears in PromptLayer as both a trace span and an associated request log without replacing the native AWS client.
This integration covers direct Boto3 bedrock-runtime calls in Python and @aws-sdk/client-bedrock-runtime calls in JavaScript. It does not instrument aioboto3 or the separate Anthropic Bedrock client.

Supported APIs

Only the language-specific surfaces in this table receive Bedrock-specific PromptLayer request log enrichment. In Python, consume or close a streaming response before flushing so its span can finish.
Bedrock auto-instrumentation uses the general OpenTelemetry Botocore or AWS SDK instrumentor. Enabling it can also trace other AWS SDK service calls made by the same process, although Bedrock-specific request log enrichment applies only to the supported Bedrock Runtime operations.

Prerequisites

  • A PromptLayer API key for the workspace that should receive the traces
  • AWS credentials, a region, and access to the Bedrock model or inference profile your application calls
  • Python 3.10 or later for Python, or Node.js 20 or later for JavaScript
Export the PromptLayer API key before the application starts. The example below also uses AWS_REGION and AWS_BEDROCK_MODEL as application configuration:
PromptLayer captures supported Bedrock message content by default. Review Capture Prompts and Responses before sending provider requests.

Python

1. Install the SDKs

2. Configure Bedrock instrumentation

Configure tracing before creating the Bedrock Runtime client or making the first request:
The canonical selector is bedrock. Python also accepts amazon.bedrock and aws.bedrock as aliases for the same Botocore instrumentor.
If your application already creates a PromptLayer client, select Bedrock when enabling tracing:
Omit tracing_providers to instrument every supported provider SDK that is installed.

JavaScript

1. Install the SDKs

2. Preload PromptLayer instrumentation

The preload must run before the application imports the AWS SDK client:

3. Use the AWS SDK normally

The preload instruments every supported provider. To instrument only Bedrock, call configureTracing({ providers: ["bedrock"] }) in a bootstrap module and dynamically import the application afterward. See Select Providers.

Capture Prompts and Responses

PromptLayer captures supported Bedrock request and response content by default. To export metadata-only telemetry, opt out before tracing is configured:
JavaScript can instead pass captureContent: false to configureTracing(). Content coverage differs by Bedrock Runtime operation: All supported operations still include non-content telemetry supplied by the instrumentor, such as the model, timing, token usage when available, and errors.
Content capture can send user messages, model responses, system instructions, tool arguments and results, and other application data to PromptLayer. Because it is enabled by default, review your privacy, retention, and compliance requirements and opt out before the first Bedrock request when necessary.

Verify the Integration

Run one supported Bedrock Runtime request, consume any Python response stream, flush or shut down tracing, and open Traces in PromptLayer. The Bedrock span should have an associated request log and identify the Converse or InvokeModel API. If no span appears:
  • Confirm instrumentation is configured before the first Bedrock Runtime request.
  • Confirm the client and operation are listed for your language in Supported APIs.
  • In JavaScript, confirm the preload or bootstrap runs before @aws-sdk/client-bedrock-runtime loads.
  • Confirm PROMPTLAYER_API_KEY belongs to the workspace you are checking.
  • For Python streaming calls, fully consume or close the stream before flushing.
  • Flush tracing before a short-lived process exits.
  • If only message content is missing, confirm content capture was not disabled, check the operation-specific coverage above, and restart the process after changing the setting.