observability/braintrust/README.md
Braintrust AI Observability exporter for Mastra applications.
npm install @mastra/braintrust
The exporter automatically reads credentials from environment variables:
# Required
BRAINTRUST_API_KEY=sk-...
# Optional
BRAINTRUST_ENDPOINT=https://api.braintrust.dev
import { BraintrustExporter } from '@mastra/braintrust';
const mastra = new Mastra({
...,
observability: {
configs: {
braintrust: {
serviceName: 'my-service',
exporters: [new BraintrustExporter()],
},
},
},
});
You can also pass credentials directly:
import { BraintrustExporter } from '@mastra/braintrust';
const mastra = new Mastra({
...,
observability: {
configs: {
braintrust: {
serviceName: 'my-service',
exporters: [
new BraintrustExporter({
apiKey: 'sk-...',
projectName: 'mastra-tracing', // Optional, defaults to 'mastra-tracing'
endpoint: 'https://api.braintrust.dev', // Optional
}),
],
},
},
},
});
| Option | Type | Description |
|---|---|---|
apiKey | string | Braintrust API key. Defaults to BRAINTRUST_API_KEY env var |
endpoint | string | Custom endpoint URL. Defaults to BRAINTRUST_ENDPOINT env var |
projectName | string | Project name. Defaults to 'mastra-tracing' |
braintrustLogger | Logger<true> | Optional Braintrust logger instance for context integration |
tuningParameters | Record<string,any> | Support tuning parameters |
logger.traced() or Eval()