Skip to main content

Laminar exporter

Laminar is an open-source, OpenTelemetry-native observability platform for AI agents. Trace, debug, and monitor every Mastra agent run, model step, tool call, and sub-agent with a single MastraExporter wired into your Observability config.

Installation
Direct link to Installation

npm install @lmnr-ai/lmnr

Configuration
Direct link to Configuration

Prerequisites
Direct link to Prerequisites

  1. Laminar Project: Create/select a project in Laminar
  2. Project API Key: Copy from Laminar Project Settings
  3. Environment Variables: Set your credentials
.env
# Required
LMNR_PROJECT_API_KEY=lmnr_...

# Optional
LMNR_BASE_URL=https://api.lmnr.ai

Zero-Config Setup
Direct link to Zero-Config Setup

With environment variables set, use the exporter with no configuration:

src/mastra/index.ts
import { Mastra } from '@mastra/core'
import { Observability } from '@mastra/observability'
import { Laminar, MastraExporter } from '@lmnr-ai/lmnr'

Laminar.initialize()

export const mastra = new Mastra({
observability: new Observability({
configs: {
laminar: {
serviceName: 'my-service',
exporters: [new MastraExporter()],
},
},
}),
})

Explicit Configuration
Direct link to Explicit Configuration

You can also pass credentials directly (takes precedence over environment variables):

src/mastra/index.ts
import { Mastra } from '@mastra/core'
import { Observability } from '@mastra/observability'
import { Laminar, MastraExporter } from '@lmnr-ai/lmnr'

Laminar.initialize({
projectApiKey: process.env.LMNR_PROJECT_API_KEY!,
baseUrl: process.env.LMNR_BASE_URL, // Optional
// ...other options
})

export const mastra = new Mastra({
observability: new Observability({
configs: {
laminar: {
serviceName: 'my-service',
exporters: [
new MastraExporter({
realtime: process.env.NODE_ENV === 'development', // Optional
}),
],
},
},
}),
})
note

For advanced usage, including the full MastraExporter options and multi-agent trace examples, see Laminar's Mastra integration guide.

Mastra also ships a standalone LaminarExporter in @mastra/laminar that sends spans over OTLP/HTTP. It cannot inherit an active OTel context and does not fully map Mastra spans to Laminar's native format, so use the @lmnr-ai/lmnr integration above for observe() wrappers, multi-agent root spans, and accurate Laminar rendering.