Skip to main content
Automatically capture all Anthropic Messages API calls.

Setup

import traceroot
from traceroot import Integration

traceroot.initialize(integrations=[Integration.ANTHROPIC])

Usage

Once initialized, all Anthropic calls are captured automatically:
import anthropic

client = anthropic.Anthropic()

# This call is automatically traced
response = 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)

What Gets Captured

AttributeDescription
Modelclaude-sonnet-4-20250514, claude-haiku-4-5-20251001, etc.
MessagesInput messages array
ResponseCompletion content
TokensInput and output tokens
CostCalculated from token usage and model pricing
LatencyRequest duration