Skip to main content
bt custom-views manages custom views defined in local TypeScript files. Use it to scaffold starter files, preview views against real data, and publish them to Braintrust without going through the browser editor.
The custom views CLI workflow is in public preview and can change before reaching general availability.
Each custom view file default-exports a definition containing its configuration and React component, using customTraceView() or customDatasetView() from braintrust/custom-views. See the TypeScript examples to write a trace or dataset view before previewing and pushing it.
bt v0.22.0 or later is required. bt custom-views push requires Node.js. Preview assets and SDK helpers are embedded in the CLI.React and the braintrust/custom-views helpers are provided by the CLI. You do not need to install them locally to bootstrap, preview, or push a view. Install any additional packages your view imports in your local project.

Subcommands

bt custom-views push

Push one or more custom view definitions to Braintrust. bt scans the path for files matching the pattern *.view.tsx, *.view.ts, *.view.jsx, *.view.js, *-view.tsx, *-view.ts, *-view.jsx, or *-view.js.
If a view with the same slug already exists, the command fails by default. Add --if-exists replace to update it. Flags Set project in each view definition, or pass --project to use the same project for all views.

bt custom-views trace bootstrap

Create a starter trace custom view file in the braintrust-custom-views/ directory (created if it does not exist). The file uses customTraceView from braintrust/custom-views and exports a React component that receives trace and span props.
Flags

bt custom-views dataset bootstrap

Create a starter dataset custom view file in the braintrust-custom-views/ directory. The file uses customDatasetView from braintrust/custom-views and exports a React component that receives input, expected, metadata, and update props.
Flags

bt custom-views trace preview

Preview a trace custom view in a local browser window using a full trace and selected span from Braintrust. The preview server serves the bundled component and hot-reloads on file changes. Edits applied from the preview stay local and are discarded on reload. They do not write to Braintrust. Open a trace in Braintrust’s logs or an experiment and copy the URL from your browser’s address bar. Pass it to --url in quotes to preserve its query parameters:
The CLI resolves the trace and selected span from the URL. If the URL does not include a project, also pass --project. You can also select a trace by root span ID and optionally select a span:
When resolving a URL, the preview server searches the last 30 days by default. Use --lookup-window to search further back. Flags

bt custom-views dataset preview

Preview a dataset custom view in a local browser window using one row’s input, expected, metadata, and tags. Select the dataset by name or ID with --dataset, or use the dataset configured in the view definition. Dataset previews do not accept --url. Edits stay local, are discarded on reload, and are not written to Braintrust.
--row-index selects a row by its zero-based position in the dataset rows returned by the API: 0 selects the first row, 1 the second, and so on. Use --row-id to select a specific row independently of ordering. If both flags are supplied, --row-id takes precedence. Flags

Example workflow

With bt v0.22.0 or later and Node.js installed, bootstrap, preview, and push a trace custom view. Copy a trace URL from your browser’s address bar for the preview step: