Skip to main content

LangSmithExporter

Sends AI tracing data to LangSmith for observability.

Constructor

new LangSmithExporter(config: LangSmithExporterConfig)

LangSmithExporterConfig

interface LangSmithExporterConfig extends ClientConfig {
logLevel?: "debug" | "info" | "warn" | "error";
client?: Client;
}

Methods

exportEvent

async exportEvent(event: AITracingEvent): Promise<void>

Exports a tracing event to LangSmith.

shutdown

async shutdown(): Promise<void>

Ends all active spans and clears the trace map.

Usage

import { LangSmithExporter } from "@mastra/langsmith";

const exporter = new LangSmithExporter({
apiKey: process.env.LANGSMITH_API_KEY,
apiUrl: "https://api.smith.langchain.com",
logLevel: "info",
});

Span Type Mapping

AI Span TypeLangSmith Type
LLM_GENERATIONllm
LLM_CHUNKllm
TOOL_CALLtool
MCP_TOOL_CALLtool
All otherschain