# LangSmithExporter
[EN] Source: https://mastra.ai/reference/observability/ai-tracing/exporters/langsmith

Sends AI tracing data to LangSmith for observability.

## Constructor

```typescript
new LangSmithExporter(config: LangSmithExporterConfig)
```

## LangSmithExporterConfig

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

<PropertiesTable
  props={[
    {
      name: "apiKey",
      type: "string",
      description: "LangSmith API key",
      required: false,
    },
    {
      name: "apiUrl",
      type: "string",
      description: "LangSmith API URL",
      required: false,
    },
    {
      name: "callerOptions",
      type: "object",
      description: "HTTP client configuration options",
      required: false,
    },
    {
      name: "hideInputs",
      type: "boolean",
      description: "Hide input data in the LangSmith UI",
      required: false,
    },
    {
      name: "hideOutputs",
      type: "boolean",
      description: "Hide output data in the LangSmith UI",
      required: false,
    },
    {
      name: "logLevel",
      type: "'debug' | 'info' | 'warn' | 'error'",
      description: "Logger level (default: 'warn')",
      required: false,
    },
    {
      name: "client",
      type: "Client",
      description: "Pre-configured LangSmith client instance",
      required: false,
    },
  ]}
/>

## Methods

### exportEvent

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

Exports a tracing event to LangSmith.

### shutdown

```typescript
async shutdown(): Promise<void>
```

Ends all active spans and clears the trace map.

## Usage

```typescript
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 Type       | LangSmith Type |
| ------------------ | -------------- |
| `MODEL_GENERATION` | `llm`          |
| `MODEL_CHUNK`      | `llm`          |
| `TOOL_CALL`        | `tool`         |
| `MCP_TOOL_CALL`    | `tool`         |
| All others         | `chain`        |


---
title: "Reference: OtelExporter | Observability"
description: OpenTelemetry exporter for AI tracing
---

import PropertiesTable from "@site/src/components/PropertiesTable";