Skip to main content
Run SQL queries against Braintrust. In a terminal, bt sql opens an interactive editor with query history. Pass a query directly or pipe from stdin for scripting.
Most SQL data-source functions also accept an object name in place of its ID. See Querying by name.

Interactive controls

Query syntax

  • A FROM clause is required (project_logs(...), experiment(...), dataset(...))
  • Prefer filtering with WHERE; use HAVING only after aggregation
  • Joins, subqueries, unions, and window functions are not supported
  • Use explicit column aliases and type casts for clarity
  • Paginate large results with OFFSET '<cursor_token>'
For tips on query performance and common pitfalls, see SQL best practices.