Overview
Laminar automatically instruments the official Anthropic package with a single line of code, allowing you to trace and monitor all your Anthropic API calls without modifying your existing code. This provides complete visibility into your AI application’s performance, costs, and behavior.Getting Started
- TypeScript
- Python
1. Install Laminar and Anthropic
2. Set up your environment variables
Store your API keys in a.env
file:If you are using Anthropic with Next.js, please follow the Next.js integration guide for best practices and setup instructions.
3. Initialize Laminar
Just add a single line at the start of your application or file to instrument Anthropic with Laminar.It is important to pass
Anthropic
to instrumentModules
as a named export.4. Use Anthropic as usual
Monitoring Your Anthropic Usage
After instrumenting your Anthropic calls with Laminar, you’ll be able to:- View detailed traces of each Anthropic API call, including request and response
- Track token usage and cost across different models
- Monitor latency and performance metrics
- Open LLM span in Playground for prompt engineering
- Debug issues with failed API calls or unexpected model outputs
Advanced Features
- Sessions - Learn how to add session structure to your traces
- Metadata - Discover how to add additional context to your LLM spans
- Trace structure - Explore creating custom spans and more advanced tracing
- Realtime Monitoring - See how to monitor your Anthropic calls in real-time