This example demonstrates auto-instrumentation of Anthropic Claude API calls.
- Install dependencies:
pip install genai-otel-instrument[anthropic]- Copy
.env.exampleto.envand add your Anthropic API key:
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY- Start an OTLP collector (e.g., Jaeger):
docker run -d --name jaeger \
-e COLLECTOR_OTLP_ENABLED=true \
-p 4318:4318 \
-p 16686:16686 \
jaegertracing/all-in-one:latest- Run the example:
python example.py- ✅ Message completions
- ✅ Streaming responses
- ✅ Token usage tracking
- ✅ Cost calculation
- ✅ Request/response metadata
- ✅ Error tracking