Skip to main content
The Braintrust API allows you to interact with all aspects of the Braintrust platform programmatically. You can use it to:
  • Create and manage projects, experiments, and datasets
  • Log traces and metrics
  • Manage prompts, tools, and scorers
  • Configure access control and permissions
  • Retrieve and analyze results
The API is defined by an OpenAPI specification published at braintrust-openapi on GitHub.

Base URL

The base URL depends on your organization’s data plane region: You can find your API URL in Settings > Data plane.

Authentication

Authenticate requests with your API key in the Authorization header:
Create API keys in Settings > API keys.

SDKs

While you can call the API directly, we recommend using one of our official SDKs:

TypeScript SDK

Official TypeScript/JavaScript SDK

Python SDK

Official Python SDK

Go SDK

Official Go SDK

Ruby SDK

Official Ruby SDK

Java SDK

Official Java SDK

C# SDK

Official C# SDK

Kotlin SDK

Official Kotlin SDK

API resources

The API is organized around REST principles. Each resource has predictable URLs and uses HTTP response codes to indicate API errors. Project resources
  • Projects: Organize your AI features and experiments
  • Experiments: Run and track evaluation experiments
  • Datasets: Manage test data for evaluations
  • Logs: Store and query production traces
  • Prompts: Version control your prompts
  • Functions: Manage tools, scorers, and workflows
  • Evals: Configure and run evaluations
  • Scores: Define custom scoring functions
  • Tags: Organize and filter project resources
  • Automations: Configure automated workflows
  • Views: Create and manage custom data views
Organization resources
  • Organizations: Manage your organization settings
  • Users: Manage team members
  • Groups: Organize users into teams
  • Roles: Define permission levels
  • ACLs: Configure fine-grained access control
  • API keys: Manage authentication credentials
  • Service tokens: Generate service-level authentication tokens
Configuration resources
  • AI secrets: Securely store API keys and credentials
  • Environment variables: Manage environment-specific configuration
  • MCP servers: Configure Model Context Protocol servers
  • Proxy: Configure proxy settings for API requests

Response format

All API responses are returned in JSON format. Successful responses will have a 2xx status code, while errors will return 4xx or 5xx status codes with error details.

Rate limits

The API uses rate limiting to ensure fair usage. Rate limits are applied per organization and endpoint. If you exceed the rate limit, you’ll receive a 429 Too Many Requests response.

Query data

Query your logs, experiments, and datasets with SQL through the /btql endpoint.

Query logs and experiments

Use the /btql endpoint to query data with SQL syntax. Data-source functions like project_logs() and experiment() accept an object name or its ID. See Querying by name for details. To control query lint warnings, set the lint_mode parameter — see Lint warnings.

Filter experiments by metadata

Filter experiments by metadata field equality using the metadata query parameter on GET /v1/experiment. Pass a JSON-serialized object to match experiments where all specified fields are equal — including nested paths:

Fetch experiment results

Query experiments to check review status or other metrics:

Fetch child spans by trace metadata

Retrieve specific child spans based on trace-level metadata:

Export data

Export logs, experiments, or datasets to JSON or Parquet:

Paginate large datasets

If you’re using the Python or TypeScript SDK, pagination is handled automatically. Only use this code if you’re developing with other tools.
For large datasets, paginate using cursors:

Write and manage data

Run experiments

Create and run experiments programmatically:

Log programmatically

Insert logs via the API:

Delete logs

Mark logs for deletion by setting _object_delete:

Impersonate users

User impersonation lets a privileged user perform an operation on behalf of another user, using the impersonated user’s identity and permissions. For example, a proxy service can forward requests from individual users to Braintrust without each user supplying their own credentials: the service authenticates with its own key and names the user to impersonate, and Braintrust runs the operation as that user. Braintrust requires that:
  • The requesting user has the Owner role over all organizations the impersonated user belongs to.
  • The impersonated user belongs to at least one organization.
Together, these requirements guarantee the requesting user has at least the set of permissions that the impersonated user has. To impersonate a user, set the x-bt-impersonate-user header to the ID or email of the user you want to impersonate. The examples below show how to configure ACLs and make a request using user impersonation:

Next steps

Support

Need help with the API?