# Braintrust Exporter
[EN] Source: https://mastra.ai/docs/observability/ai-tracing/exporters/braintrust

[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 AI traces to Braintrust, enabling systematic evaluation, scoring, and experimentation.

## When to Use Braintrust

Braintrust excels at:

- **Evaluation workflows** - Systematic quality measurement
- **Experiment tracking** - Compare model versions and prompts
- **Dataset management** - Curate test cases and golden datasets
- **Regression testing** - Ensure improvements don't break existing functionality
- **Team collaboration** - Share experiments and insights

## Installation

```bash npm2yarn
npm install @mastra/braintrust
```

## 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 title=".env"
BRAINTRUST_API_KEY=sk-xxxxxxxxxxxxxxxx
BRAINTRUST_PROJECT_NAME=my-project  # Optional, defaults to 'mastra-tracing'
```

### Basic Setup

```typescript title="src/mastra/index.ts"
import { Mastra } from "@mastra/core";
import { BraintrustExporter } from "@mastra/braintrust";

export const mastra = new Mastra({
  observability: {
    configs: {
      braintrust: {
        serviceName: "my-service",
        exporters: [
          new BraintrustExporter({
            apiKey: process.env.BRAINTRUST_API_KEY,
            projectName: process.env.BRAINTRUST_PROJECT_NAME,
          }),
        ],
      },
    },
  },
});
```

### 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

- [AI Tracing Overview](/docs/observability/ai-tracing/overview)
- [Braintrust Documentation](https://www.braintrust.dev/docs)


---
title: "Cloud Exporter | AI Tracing | Observability"
description: "Send traces to Mastra Cloud for production monitoring"
---