Skip to main content
The CoreWeave Forge SDK automatically traces calls you make with the Anthropic SDK for Python and Node.js. After you initialize tracing, each call you make inside a conversation is recorded in Agent Lens as an LLM span with its messages, tool calls, media, request settings, token usage, and prompt-cache usage. You don’t change how you call the Anthropic SDK. The integration traces the Messages API, including streaming, the Messages stream helper, and structured-output parsing. In TypeScript, it also traces Message Batches API calls as tool operations.

Prerequisites

  • A CoreWeave Forge account and API key set as a WANDB_API_KEY environment variable.
  • An Anthropic API key set as an ANTHROPIC_API_KEY environment variable.
  • For Python: Python 3.10 or later and anthropic 0.18.0 or later.
  • For TypeScript: Node.js 18.19 or later (or 20.6 or later) and @anthropic-ai/sdk 0.52.0 or later.

Install packages

Trace Anthropic conversations

Call tracing.init() with your Forge team and project names. In Python, tracing.init() patches the Anthropic SDK, whether you import it before or after the call. In TypeScript, start Node with the instrumentation flag shown in the TypeScript tab. Agent Lens shows only calls that run inside a conversation. A call made outside a conversation has no conversation ID, so it doesn’t appear in Agent Lens. Create one conversation for each agent session, and start a turn for each user message. Every turn shares the conversation’s ID, so Agent Lens groups the turns into one conversation, and each call becomes an LLM span of the turn it runs in.
To add turns to an existing conversation later, such as in a web app that handles one turn per request, pass the same conversation_id (Python) or conversationId (TypeScript) each time you create the conversation. For more about conversations, turns, and the other span types, see Trace your agents.

Turn off automatic patching

In Python, pass autopatch_integrations=False to tracing.init(). You can then patch and unpatch the Anthropic SDK yourself with tracing.integrations.patch_anthropic() and tracing.integrations.unpatch_anthropic(). In TypeScript, run without the --import=@coreweave/forge-sdk/instrument flag, and wrap only the clients you want to trace with integrations.wrapAnthropic().

View your traces

In CoreWeave Forge, select Agent Lens from the product menu, select your project in the project selector at the top of the side menu, and then select Conversations. For more information, see View agent activity.
Last modified on September 30, 2026