Skip to main content
You can send Anthropic traces to LangSmith from Anthropic’s servers or from your own application:
  • From the Claude Platform: The Claude Platform sends traces directly from Anthropic’s servers. You configure it in the Claude Console, with no changes to your application code.
  • From your application: Your application sends the traces, in one of two ways:
    • Claude SDKs: The Claude SDKs emit OpenTelemetry (OTel) spans, and an OTel exporter library sends them to LangSmith.
    • LangSmith SDK wrapper: You wrap the Anthropic client with the LangSmith SDK (Python or TypeScript). You can combine the traces with @traceable spans for the rest of your code in a single trace.
Tracing from the Claude Platform and the Claude SDKs is in public beta.

Trace from the Claude Platform

The Claude Platform exports OTel traces of your Claude Managed Agents sessions and Messages API requests. It sends them to a destination, an OTel endpoint that you register in the Claude Console. You can add LangSmith as a destination and view these traces without changing your application code. For details on destinations and delivery, see Use OpenTelemetry with the Claude API in the Anthropic docs. Before you begin, you need:
  • The admin role, or an equivalent permission, in your Claude Console organization. Without it, you cannot view or manage destinations.
  • A LangSmith API key. You can use a personal access token, or a service key when you want tracing to be independent of your user account. To create a key, see Create an account and API key.
  • For self-hosted LangSmith, an endpoint that the Claude Platform can reach: HTTPS on port 443, at a hostname that resolves to a public IP address.

Step 1. Add LangSmith as a destination

To add a destination:
  1. In the Claude Console, open the OpenTelemetry settings page of your organization and click Add destination.
  2. In the Provider drop-down, select LangSmith. The form changes to show the LangSmith fields.
  3. Complete the fields:
    • Name: (Optional) A label for the destination, such as LangSmith.
    • Region: The region of your LangSmith deployment: US, EU, APAC, or US on AWS. For self-hosted LangSmith, select Self-hosted and enter the OTel endpoint URL of your instance in the LangSmith URL field, for example https://<your-langsmith-host>/api/v1/otel.
    • API key: Your LangSmith API key.
    • Project: (Optional) The name of the tracing project to send traces to. If you leave it empty, traces go to the default project.
    • LangSmith workspace ID: (Optional) The ID of the LangSmith workspace to send traces to. If you leave it empty, traces go to the workspace that the API key belongs to. Organization-scoped service keys require it. To find the ID, see Create an account and API key.
    • Content mode: Select Full content to include prompts and responses in the spans. With Metadata only, spans omit the input and output content.
    • Workspaces: The Claude workspaces that send traces to this destination: All, Selected, or All except. For details on each option, see Choose workspaces for a destination in the Anthropic docs.
  4. Click Add destination.
When you edit the destination later, the form shows the generic OTLP endpoint URL and Request headers fields instead of the LangSmith fields. The OTLP endpoint URL holds the URL of your region, and the LangSmith fields become these request headers:
  • x-api-key: The API key.
  • Langsmith-Project: The Project, if you set one.
  • X-Tenant-Id: The LangSmith workspace ID, if you set one.
If you change the host of the OTLP endpoint URL, enter the header values again.

Step 2. Check that traces arrive

To check the setup:
  1. Send a Messages API request or run a Claude Managed Agents session in a Claude workspace that uses the destination.
  2. On the Claude Console OpenTelemetry settings page, check that the Delivery column of the destination shows Healthy. This can take about a minute.
  3. In LangSmith, open the project that you named in the Project field, or the default project.

Troubleshoot delivery

If the Delivery column on the Claude Console OpenTelemetry settings page shows Failing, hold the pointer over it to see the last error:
  • HTTP 401: The destination sends no API key.
  • HTTP 403: The API key is wrong, or it has expired or been deleted. LangSmith also returns 403 for an organization-scoped service key without a workspace ID.
  • HTTP 404: The endpoint URL is wrong. Edit the destination and check that the OTLP endpoint URL ends in /otel (/api/v1/otel for self-hosted LangSmith) and does not include /v1/traces.
For other errors, see Delivery errors in the Anthropic docs. If the Delivery column shows Disabled, hold the pointer over it to see why. For example, the Claude Platform disables a destination whose hostname resolves to an IP address that is not public. See Delivery and health in the Anthropic docs.

Trace from your application

Use one of these methods when your application should send the traces. To trace your Anthropic calls together with the rest of your code in a single trace, use the LangSmith SDK wrapper.

Use the Claude SDKs

The Claude SDKs emit OTel spans in your application for each request that they send and for each tool use that the tool runner runs. An OTel exporter library sends the spans to LangSmith. For details on the SDK options and the spans that the SDKs emit, see Set up SDK tracing in the Anthropic docs. To send Claude SDK spans to LangSmith:
  1. Install or upgrade the Claude SDK and register a tracer provider.
  2. Configure an OTel exporter with the OTel endpoint URL of your LangSmith deployment: Set the following request headers:
    • x-api-key: Your LangSmith API key.
    • Langsmith-Project: (Optional) The name of the tracing project to send traces to. Without this header, traces go to the default project.
    • X-Tenant-Id: (Optional) The ID of the LangSmith workspace to send traces to. Without this header, traces go to the workspace that the API key belongs to. Organization-scoped service keys require it.
    For example, with the standard OTel environment variables:
    For more information on exporter setup, see Trace a non-LangChain application.
  3. (Optional) By default, the Claude SDKs record metadata only. To include prompts and responses in the spans, set the content mode. See Configure the SDK in the Anthropic docs.

Use the LangSmith SDK wrapper

The Anthropic wrapper methods in Python (wrap_anthropic) and TypeScript (wrapAnthropic) wrap your Anthropic client to log traces automatically. With the wrapper, LangSmith renders messages, including tool calls and multimodal content blocks, in a readable format. The wrapper works alongside the @traceable decorator (Python) or traceable function (TypeScript), so you can trace your Anthropic calls with the wrapper and trace other parts of your application with the decorator or function.
Set the LANGSMITH_TRACING environment variable to 'true' to log traces to LangSmith, even when you use wrap_anthropic or wrapAnthropic. This lets you toggle tracing on and off without changing your code.Also set the LANGSMITH_API_KEY environment variable to your API key. To create a key, see Create an account and API key.If your LangSmith API key is linked to multiple workspaces, set the LANGSMITH_WORKSPACE_ID environment variable to specify which workspace to use.By default, LangSmith logs traces to a project named default. To log traces to a different project, see Log traces to a specific project.
To trace Claude Managed Agents sessions with the TypeScript wrapAnthropic wrapper, see Trace Claude Managed Agents.