observability/langsmith/README.md
LangSmith AI Observability exporter for Mastra applications.
npm install @mastra/langsmith
The exporter automatically reads credentials from environment variables:
# Required
LANGSMITH_API_KEY=lsv2_pt_...
# Optional
LANGCHAIN_PROJECT=my-project # Project name, defaults to "default"
import { LangSmithExporter } from '@mastra/langsmith';
const mastra = new Mastra({
...,
observability: {
configs: {
langsmith: {
serviceName: 'my-service',
exporters: [new LangSmithExporter()],
},
},
},
});
You can also pass credentials directly:
import { LangSmithExporter } from '@mastra/langsmith';
const mastra = new Mastra({
...,
observability: {
configs: {
langsmith: {
serviceName: 'my-service',
exporters: [
new LangSmithExporter({
apiKey: 'lsv2_pt_...',
projectName: 'my-custom-project', // Optional
}),
],
},
},
},
});
| Option | Type | Description |
|---|---|---|
apiKey | string | LangSmith API key. Defaults to LANGSMITH_API_KEY env var |
projectName | string | The name of the LangSmith project to send traces to. Overrides LANGCHAIN_PROJECT env var |
apiUrl | string | Custom LangSmith API URL (for self-hosted instances) |
client | Client | Custom LangSmith client instance |