# Braintrust Exporter [Braintrust](https://www.braintrust.dev/) is an evaluation and monitoring platform that helps you measure and improve LLM application quality. The Braintrust exporter sends your traces to Braintrust, enabling systematic evaluation, scoring, and experimentation. ## Installation ```bash npm install @mastra/braintrust@latest ``` ```bash pnpm add @mastra/braintrust@latest ``` ```bash yarn add @mastra/braintrust@latest ``` ```bash bun add @mastra/braintrust@latest ``` ## Configuration ### Prerequisites 1. **Braintrust Account**: Sign up at [braintrust.dev](https://www.braintrust.dev/) 2. **Project**: Create or select a project for your traces 3. **API Key**: Generate in Braintrust Settings → API Keys 4. **Environment Variables**: Set your credentials: ```bash BRAINTRUST_API_KEY=sk-xxxxxxxxxxxxxxxx # Optional BRAINTRUST_ENDPOINT=https://api.braintrust.dev # Custom endpoint if needed ``` ### Zero-Config Setup With environment variables set, use the exporter with no configuration: ```typescript import { Mastra } from "@mastra/core"; import { Observability } from "@mastra/observability"; import { BraintrustExporter } from "@mastra/braintrust"; export const mastra = new Mastra({ observability: new Observability({ configs: { braintrust: { serviceName: "my-service", exporters: [new BraintrustExporter()], }, }, }), }); ``` ### Explicit Configuration You can also pass credentials directly (takes precedence over environment variables): ```typescript import { Mastra } from "@mastra/core"; import { Observability } from "@mastra/observability"; import { BraintrustExporter } from "@mastra/braintrust"; export const mastra = new Mastra({ observability: new Observability({ configs: { braintrust: { serviceName: "my-service", exporters: [ new BraintrustExporter({ apiKey: process.env.BRAINTRUST_API_KEY, projectName: "my-project", }), ], }, }, }), }); ``` ### Complete Configuration ```typescript new BraintrustExporter({ // Required apiKey: process.env.BRAINTRUST_API_KEY!, // Optional settings projectName: "my-project", // Default: 'mastra-tracing' endpoint: "https://api.braintrust.dev", // Custom endpoint if needed logLevel: "info", // Diagnostic logging: debug | info | warn | error }); ``` ## Related - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview/llms.txt) - [Braintrust Documentation](https://www.braintrust.dev/docs)