Skip to main content
The Anthropic wrapper methods in Python (wrap_anthropic) and Typescript (wrapAnthropic) allow you to wrap your Anthropic client in order to log traces automatically. Using the wrapper ensures that messages, including tool calls and multimodal content blocks will be rendered nicely in LangSmith. The wrapper works seamlessly 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. The wrapper also supports Claude managed agents (TypeScript only). Refer to Trace Claude managed agents.
The LANGSMITH_TRACING environment variable must be set to 'true' in order for traces to be logged to LangSmith, even when using wrap_anthropic or wrapAnthropic. This allows you to toggle tracing on and off without changing your code.Additionally, you will need to set the LANGSMITH_API_KEY environment variable to your API key (see Setup for more information).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, the traces will be logged to a project named default. To log traces to a different project, see Log traces to a specific project.

Trace Claude managed agents

The wrapAnthropic wrapper also supports Claude managed agents (TypeScript only). Wrap the Anthropic client with wrapAnthropic. The wrapper will automatically trace agent creation, session creation, and all events that flow through the session.
TypeScript
Full tracing of subagents in Anthropic’s multi-agent architecture requires tapping into a separate event stream and is not yet supported. Only top-level session events are traced.