Setup
Install Braintrust alongside the Flue runtime, CLI, then set your API keys. Install@flue/runtime and @flue/cli together so their versions stay aligned.1
Install packages
2
Set environment variables
.env
Register the Braintrust observer
Initialize Braintrust in your Flue app entry, then passbraintrustFlueObserver to Flue’s observe(...) API. The observer receives Flue runtime events and reports workflow events as traces to Braintrust.1
Configure your Flue project
Flue loads its app entry from
src/app.ts, discovered through a flue.config.ts at the project root. Running flue init --target node generates this config:flue.config.ts
2
Initialize Braintrust and observe Flue
Call
initLogger and observe(braintrustFlueObserver) at the entrypoint of your application, so Braintrust is ready before any workflow runs:src/app.ts
3
Run your app
Run Flue normally. The app entry subscribes Braintrust to Flue activity.
What Braintrust traces
Braintrust captures:- Workflow run spans (
workflow:<name>), with the run input and result. - Operation spans (
flue.prompt,flue.skill, andflue.compact) for agent operations. - LLM turn spans (
llm:<model>), with messages as input, the model and request parameters as metadata, and the response as output. - Tool call spans (
tool:<name>), with the tool arguments as input and the tool result as output. - Subtask spans (
task:<agent>), with the subtask prompt as input and its result as output. - Context compaction spans (
compaction:<reason>), with message counts before and after compaction. - Token usage and cost metrics (prompt, completion, total, cached, cache-creation, and estimated cost) on LLM turns.
- Errors captured on every span.