Skip to main content
PromptLayer can auto-instrument the official Anthropic SDK and export supported calls as OpenTelemetry spans. Each supported direct SDK call appears in PromptLayer as both a trace span and an associated request log without changing how you create or use the Anthropic client.
This guide covers the Anthropic model SDK. If you use the Claude Agent SDK or Claude Code, follow the Claude integration instead.

Supported APIs

Not documented means the surface is outside the verified coverage for that language. The Anthropic Bedrock client is not included in this provider integration. To trace direct Boto3 or AWS SDK v3 Bedrock Runtime calls, follow the AWS Bedrock guide. Other Anthropic SDK calls continue to work normally, but unsupported surfaces do not automatically create PromptLayer traces or request logs.

Prerequisites

  • A PromptLayer API key for the workspace that should receive the traces
  • An Anthropic API key, or the standard Google Cloud credentials and project configuration for Anthropic Vertex
  • Python 3.10 or later for Python, or Node.js 20 or later for JavaScript
Export the direct Anthropic API keys before the application starts:
PromptLayer captures supported message content by default. Review the content-capture behavior and opt-out values before sending provider requests.

Python

1. Install the SDKs

Install Anthropic’s Vertex dependencies if your application uses AnthropicVertex.

2. Configure Anthropic instrumentation

The same anthropic selector instruments AnthropicVertex. Sync and async clients are supported.
If your application already creates a PromptLayer client, select Anthropic when enabling tracing:
Omit tracing_providers to instrument every supported provider SDK that is installed.

JavaScript

1. Install the SDKs

For Anthropic Vertex, also install @anthropic-ai/vertex-sdk.

2. Preload PromptLayer instrumentation

The preload must run before the application imports the Anthropic SDK:

3. Use the Anthropic SDK normally

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

Verify the Integration

Run one supported Anthropic request, flush or shut down tracing, and open Traces in PromptLayer. The Anthropic span should have an associated request log. If no span appears:
  • Confirm instrumentation is configured before the first Anthropic request.
  • In JavaScript, confirm the preload or bootstrap runs before the Anthropic SDK module loads.
  • Confirm the call uses an API surface listed in Supported APIs.
  • Confirm PROMPTLAYER_API_KEY belongs to the workspace you are checking.
  • Flush or shut down tracing before a short-lived process exits.