Skip to main content

Lanternfish docs

Build from first trace to first briefing

Browse documentation
A
Integration

Anthropic

Automatic tracing for Anthropic Claude API calls including Claude 3.5 Sonnet, Opus, Haiku, and tool use.

Prerequisites

  • Anthropic API key
  • Lanternfish SDK installed
1

Install the SDK

bash
pip install "lanternfish[anthropic]"
2

Initialize with auto-instrument

python
import os
import lanternfish
from anthropic import Anthropic

# Simply call instrument() and Anthropic calls are auto-traced
lanternfish.instrument(
    api_key=os.environ["LANTERNFISH_API_KEY"],
    endpoint=os.environ["LANTERNFISH_ENDPOINT"],
)

client = Anthropic()
3

Use as normal — tracing is automatic

python
# Anthropic Claude calls are automatically traced
message = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Analyze this dataset"}
    ],
)

# Captures: Claude model, input/output tokens, and cost breakdown
print(message.content[0].text)

What Lanternfish captures

  • Complete trace timeline
  • Token usage and cost
  • Latency metrics
  • Tool and function calls
  • Error tracking
  • Model information

Next steps