GeezerVison is showing docs.braintrust.dev — Set up tracing - Braintrust Connect to Braintrust
Connect your coding agent to Braintrust so it can work with your traces, datasets, scorers, and experiments as you improve your app.
Add the Braintrust MCP server to your coding agent using your region’s endpoint:https://api.braintrust.dev/mcp
https://api-eu.braintrust.dev/mcp
When prompted, sign in to Braintrust and approve access. Clients without OAuth support can use an API key instead. Install the Braintrust CLI in the environment where your coding agent runs:curl -fsSL https://bt.dev/cli/install.sh | bash
bt --version
powershell -ExecutionPolicy Bypass -c "irm https://github.com/braintrustdata/bt/releases/latest/download/bt-installer.ps1 | iex"
bt --version
Sign in and save a profile:bt login --oauth --profile <your-profile>
Add tracing
Traces show how your app produced a result, including its model calls, tool calls, and intermediate outputs. You’ll use them to investigate failures and build test cases. The setup below configures the Braintrust SDK and API key in your app.
In your project directory, give this prompt to your coding agent:# Trace an AI application with Braintrust
Set up Braintrust tracing in this working directory. Follow these steps in order.
## Step 1: Set up Braintrust access
Check whether `BRAINTRUST_API_KEY` is set in the environment. If it is, skip this step.
If it isn't, ask the user to do the following, then stop and wait for the user to confirm. Do not guess, invent, or hardcode an API key.
1. Sign up or sign in at https://www.braintrust.dev/signup
2. Create an API key at https://www.braintrust.dev/app/~/configuration/api-keys
3. Set `BRAINTRUST_API_KEY` (the value starts with `sk-`) as an environment variable in the shell the user will run the app from, for example `export BRAINTRUST_API_KEY="sk-..."`. If the app loads a `.env` file, add it there instead. The user should not commit the key to version control.
Once the user confirms, continue. If the key isn't visible in your own environment, that's expected when the user set it in a separate shell or in a `.env` file that only the app loads. Don't block on it.
## Step 2: Detect the SDK
Look at the workspace and determine the right Braintrust SDK(s) to use. If the project spans more than one language, instrument each one. If the project is a monorepo, check the git root to get oriented, but only instrument applications in or below the current working directory.
## Step 3: Follow the SDK's configure tracing guide
For each SDK, read the matching page and follow its "Configure tracing" section. Do not follow any other Braintrust setup docs.
| SDK | Guide |
| --- | ------|
| Python | https://docs.braintrust.dev/sdks/python/install-and-instrument.md |
| TypeScript | https://docs.braintrust.dev/sdks/typescript/install-and-instrument.md |
| Go | https://docs.braintrust.dev/sdks/go/install-and-instrument.md |
| Java | https://docs.braintrust.dev/sdks/java/install-and-instrument.md |
| Ruby | https://docs.braintrust.dev/sdks/ruby/install-and-instrument.md |
| C# | https://docs.braintrust.dev/sdks/csharp/install-and-instrument.md |
## Step 4: Install and configure the SDK
- Install the SDK with the package manager the project already uses. Use the latest version: look it up and install that version rather than pinning to `latest`. Verify the install succeeded.
- Prefer auto-instrumentation over manual wrappers.
- Set the project name in the SDK initialization to the repository or application name. If the user has a specific Braintrust project in mind, use that instead.
## Rules
- Add only tracing. Do not add evals or anything else.
- Preserve the app's existing model provider and routing.
- Make only the code changes needed to add tracing. Do not run application code, and do not break or meaningfully modify existing code.
- Do not use the Braintrust CLI (`bt`).
Full documentation: https://docs.braintrust.dev/llms.txt
This sets up access to Braintrust, then uses a coding agent to inspect your project, install the Braintrust SDK, and configure tracing.No coding agent installed? Install and instrument manually. In your project directory, run the agent-assisted setup wizard:curl -fsSL https://braintrust.dev/wizard/setup.sh | sh -s -- --from docs_tracing_quickstart
This sets up access to Braintrust, then uses a coding agent to inspect your project, install the Braintrust SDK, and configure tracing.No coding agent installed? Install and instrument manually.
Verify tracing
Run your app and make an AI call. A trace will show up in your Logs within seconds.
Open a trace and inspect its input and output. Then expand a model or tool call to see that step’s input, output, and duration. These individual steps, called spans, help you understand how the app reached its result. You can also inspect token counts and cost.
If your traces don’t appear in Braintrust, see Troubleshoot below.
Troubleshoot
MCP client can't connect?
- Check that the endpoint matches your organization’s data plane region.
- If your client asks for a transport, choose HTTP (also called streamable HTTP). SSE-only clients can’t connect.
- See Troubleshooting for more fixes.
- Run
bt login --oauth --profile <your-profile> again, or set BRAINTRUST_API_KEY in the shell your agent uses.
- On a headless machine, run
bt login --no-browser.
Not seeing traces in the UI?
- Verify
BRAINTRUST_API_KEY is set and starts with sk-.
- Check that the project name in your code matches the project in the UI.
- Check your console for errors. Common causes are an invalid API key, network connectivity, or a firewall blocking
api.braintrust.dev.
Next steps
Find problems with PatternsIdentify recurring issues in your traces with Patterns.
For more tracing options, see the tracing guide. |