bt is the command-line interface for Braintrust. It lets you authenticate, trace coding-agent sessions, run evals, browse and query logs, sync data, and manage functions without leaving your terminal.
MCP or CLI?
MCP or CLI?
Which one you want depends on what your tool can access and where the work needs to run.
- MCP: Best when your AI tool can connect to Braintrust but has no authenticated shell, which is common in chat applications. It also fits when you want an assistant to reason over your Braintrust data and take several connected actions in one conversation, without installing and maintaining a CLI in its execution environment.
btCLI: Best for repeatable work in scripts, CI, local files, and shell pipelines, where you want deterministic commands instead of an assistant’s judgment. Coding agents with shell access can call those commands too.
Install
Choose an installation method:- Standalone
- npm
- pnpm
- mise
Install the latest version of
bt:Authenticate and set context
1
Choose how to authenticate
bt supports three authentication methods:- Environment API key
- Saved OAuth profile
- Saved API key profile
BRAINTRUST_API_KEY supplies an API key directly for the current shell session. bt does not save it in a profile, and it overrides any saved profile.Set the environment variable:2
Select an organization and project
Next, select the active profile, organization, and project that
bt should use by default:bt switch handles authentication in two ways:- Environment API key: If
BRAINTRUST_API_KEYis set,bt switchauthenticates with it instead of selecting a saved profile. - Saved profile: If
BRAINTRUST_API_KEYis not set,bt switchprompts you to select a saved profile (when there are multiple to choose from), then authenticates with that profile.
Override organization and project context
Override organization and project context
You can override the saved context at two scopes:
- Single command: Pass
--org(-o) or--project(-p). Command-line flags override both environment variables and saved context. - Current environment: Set
BRAINTRUST_ORG_NAMEorBRAINTRUST_DEFAULT_PROJECT. These variables override saved context for commands run in that environment.
bt switch, the organization and project overrides are also saved as the new active context (but not BRAINTRUST_API_KEY).3
Verify authentication and context
Inspect the completed setup:Use the output to confirm:
- Saved profiles: Each profile you intend to use authenticates successfully.
- Active context: The selected profile, organization, and project are correct.
bt status --all reports when BRAINTRUST_API_KEY overrides saved profiles, but it does not validate the key. If you use this variable, a successful bt switch in the previous step confirms that the key can authenticate.For details about how
bt chooses between environment API keys and saved profiles, see Credential precedence.Trace coding-agent sessions
bt trace enable installs a tracing plugin for your coding agent to trace future sessions to Braintrust, including turns, model calls, and tool use. Use bt v0.19.3 or later for Grok tracing and the v2 OpenCode and pi integrations. Run the command for your agent:
Instrument your project
In your project directory, run the agent-assisted setup wizard:bt is already installed or authenticated.
Run evals locally
Run your evaluation files directly withoutnpx or SDK runner setup:
bt eval auto-detects your JavaScript runner (tsx, vite-node, ts-node) and supports Python eval files too. For other languages, run your eval file directly with your language’s toolchain. See bt eval for the full list of flags.
Run evals in CI
For CI pipelines, setBRAINTRUST_API_KEY instead of using OAuth login. See Run in CI/CD for the full workflow.
--no-input and --jsonl for non-interactive output:
--first N or --sample N to run a subset of your data as a non-final smoke run on pull requests, then run the full suite on merge:
Browse and query logs
bt view logs opens an interactive terminal UI for browsing your project’s logs, useful for checking on production traffic or debugging during an incident:
bt sql runs SQL queries against your logs from the terminal or in scripts.
By default, FROM logs queries the active project in bt’s local or global context. The --project flag or BRAINTRUST_DEFAULT_PROJECT selects a different project for the command. In scripts without saved context, pass --project explicitly:
bt view and bt sql for details.
Sync data
bt sync downloads Braintrust data to local NDJSON files for offline analysis, backup, or migration:
bt sync for the full flag reference.
Manage functions
bt functions push uploads local TypeScript or Python function definitions (tools, scorers, and LLM functions) to Braintrust. bt functions pull downloads them back to local files.
bt functions for bundling behavior, language options, and all flags.
Next steps
- Read the CLI overview for the complete command list, global flags, and environment variables
- See Filter and search logs for SQL query examples against your logs
- See Run evaluations for eval workflow details