import Anthropic from '@anthropic-ai/sdk';import * as anthropicSDK from '@anthropic-ai/sdk';import { TraceRoot } from '@traceroot-ai/traceroot';TraceRoot.initialize({ instrumentModules: { anthropic: anthropicSDK } });const client = new Anthropic();
Once initialized, all Anthropic calls are captured automatically:
Python
TypeScript
import anthropicclient = anthropic.Anthropic()# This call is automatically tracedresponse = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[ {"role": "user", "content": "What is the capital of France?"}, ],)print(response.content[0].text)
import Anthropic from '@anthropic-ai/sdk';const client = new Anthropic();// This call is automatically tracedconst response = await client.messages.create({ model: 'claude-sonnet-4-20250514', max_tokens: 1024, messages: [ { role: 'user', content: 'What is the capital of France?' }, ],});console.log(response.content[0].text);