Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

LangSmithExporter

Sends AI tracing data to LangSmith for observability.

ConstructorDirect link to Constructor

new LangSmithExporter(config: LangSmithExporterConfig)

LangSmithExporterConfigDirect link to LangSmithExporterConfig

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

MethodsDirect link to Methods

exportEventDirect link to exportEvent

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

Exports a tracing event to LangSmith.

shutdownDirect link to shutdown

async shutdown(): Promise<void>

Ends all active spans and clears the trace map.

UsageDirect link to 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 MappingDirect link to Span Type Mapping

AI Span TypeLangSmith Type
MODEL_GENERATIONllm
MODEL_CHUNKllm
TOOL_CALLtool
MCP_TOOL_CALLtool
All otherschain