To use an agent for automatic setup, see the Quickstart.
Sign up
If you don’t have a Braintrust account, sign up for free at braintrust.dev.Install the SDK
Add the Braintrust SDK to your project:Set an API key
Create an API key in API key settings and set it as an environment variable:.env
Configure tracing
There are two ways to instrument your app:- Auto-instrumentation (recommended): The SDK automatically traces supported AI provider gems.
- Manual instrumentation: Initialize Braintrust yourself and instrument specific provider clients. Use this approach if you need precise control over when instrumentation runs.
- Auto-instrumentation
- Manual instrumentation
Initialize the SDK
Auto-instrumentation patches supported AI libraries before you make provider calls. Pick the setup style that fits your app:

Bundler applications
Bundler applications
Add the SDK to your Gemfile with Make sure your application loads Bundler before requiring application code:When
require: "braintrust/setup":Gemfile
app.rb
braintrust/setup loads, it calls Braintrust.init and instruments the supported provider gems already loaded in the process. List provider gems before braintrust in your Gemfile so Bundler.require loads them first. Gems loaded after braintrust/setup runs are not instrumented.
Rails
Rails
Add the SDK to your Gemfile with Rails loads Bundler during boot, so the setup file runs as the app starts. If you prefer an initializer, require the setup file there instead:
require: "braintrust/setup":Gemfile
config/initializers/braintrust.rb
CLI wrapper
CLI wrapper
To instrument a Ruby process without changing application source code, install the gem and wrap the command with Use
braintrust exec:--only or --except to filter integrations:Find your AI provider
To learn more about what gets traced, find your AI provider in SDK integrations.
Verify tracing
Run your app and make an AI call. A trace will show up in your Braintrust Logs, usually within seconds.If traces appear in Braintrust, you’ve successfully set up the SDK.
Next steps
Learn more about using the SDK to observe, evaluate, and improve your AI application:- Instrument — trace LLM calls and application logic
- Observe — search and analyze production traces
- Annotate — label traces and build datasets
- Evaluate — measure quality and catch regressions
- Deploy — ship to production with the AI gateway