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:Using Anthropic inside Next.js? The Vercel AI SDK page covers the Next.js-specific setup (
serverExternalPackages, instrumentation.ts, and Laminar.patch for direct SDK clients).3. Initialize Laminar
Just add a single line at the start of your application or file to instrument Anthropic with Laminar.import Anthropic from '@anthropic-ai/sdk' imports the module. Pass it to
instrumentModules, then create the client with new Anthropic.Anthropic().4. Use Anthropic as usual
Monitoring 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
Enrich your Anthropic traces
- Attach sessions, user IDs, metadata, and tags to Anthropic spans via the SDK reference.
- Wrap the functions around your Anthropic calls with
observeand mark them as TOOL spans so they show up in the transcript.
Related integrations
OpenAI
Trace the OpenAI SDK directly in TypeScript and Python.
Gemini
Trace Gemini calls made with the Google Gen AI SDK.
OpenRouter
Trace OpenRouter requests with model and cost attribution.
Claude Agent SDK
Trace Claude Agent SDK runs and their subagents.
Vercel AI SDK
Trace
generateText and streamText in Next.js and Node.js.All integrations
Browse every provider, framework, coding agent, and browser integration Laminar supports.