This approach instruments all supported libraries automatically.
Copy
import { Laminar } from '@lmnr-ai/lmnr';// Initialize before importing LLM librariesLaminar.initialize({ projectApiKey: process.env.LMNR_PROJECT_API_KEY});// Import after initializationimport { OpenAI } from 'openai';import Anthropic from '@anthropic-ai/sdk';
This approach may not work with all bundlers. If you encounter issues, use selective instrumentation instead.
For better control and compatibility, instrument only the libraries you need.
Recommended approach for JavaScript/TypeScript applications:
Copy
import { OpenAI } from 'openai';import Anthropic from '@anthropic-ai/sdk';import { Laminar } from '@lmnr-ai/lmnr';Laminar.initialize({ projectApiKey: process.env.LMNR_PROJECT_API_KEY, instrumentModules: { openai: OpenAI, anthropic: Anthropic }});// Both OpenAI and Anthropic calls are now tracedconst openaiClient = new OpenAI();const anthropicClient = new Anthropic();
import { Laminar } from '@lmnr-ai/lmnr';Laminar.initialize({ projectApiKey: process.env.LMNR_PROJECT_API_KEY, instrumentModules: {} // Empty object = no instrumentation});// No LLM calls will be automatically traced// Use manual instrumentation instead