BraintrustExporter
Sends AI tracing data to Braintrust for eval and observability.
Constructor
new BraintrustExporter(config: BraintrustExporterConfig)
BraintrustExporterConfig
interface BraintrustExporterConfig {
apiKey?: string;
endpoint?: string;
projectName?: string;
logLevel?: 'debug' | 'info' | 'warn' | 'error';
tuningParameters?: Record<string, any>;
}
Methods
exportEvent
async exportEvent(event: AITracingEvent): Promise<void>
Exports a tracing event to Braintrust.
export
async export(spans: ReadOnlyAISpan[]): Promise<void>
Batch exports spans to Braintrust.
shutdown
async shutdown(): Promise<void>
Flushes pending data and shuts down the client.
Usage
import { BraintrustExporter } from '@mastra/braintrust';
const exporter = new BraintrustExporter({
apiKey: process.env.BRAINTRUST_API_KEY,
projectName: 'my-ai-project',
});
Span Type Mapping
AI Span Type | Braintrust Type |
---|---|
LLM_GENERATION | llm |
LLM_CHUNK | llm |
TOOL_CALL | tool |
MCP_TOOL_CALL | tool |
WORKFLOW_CONDITIONAL_EVAL | function |
WORKFLOW_WAIT_EVENT | function |
All others | task |