- 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
Base URL
The base URL depends on your organization’s data plane region:| Region | Base URL |
|---|---|
| US | https://api.braintrust.dev |
| EU | https://api-eu.braintrust.dev |
| Self-hosted | Your custom data plane URL |
Authentication
Authenticate requests with your API key in the Authorization header: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 a2xx 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 a429 Too Many Requests response.
Common tasks
Invoke functions
Call prompts, tools, or scorers via the/v1/function endpoint:
project_nameorproject_id: Project containing the functionslug: Function sluginput: Function input parametersversion(optional): Pin to a specific versionenvironment(optional): Use environment-specific versionstream(optional): Enable streaming responses
Query logs and experiments
Use the/btql endpoint to query data with SQL syntax. To control query lint warnings, set the lint_mode parameter — see Lint warnings.
Filter experiments by metadata
Filter experiments by metadata field equality using themetadata 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.
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
Ownerrole over all organizations the impersonated user belongs to. - The impersonated user belongs to at least one organization.
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
- Explore the complete API reference for all available endpoints
- Learn about SQL querying to analyze your data
- Review system limits for API usage constraints
- Check out the Python SDK or TypeScript SDK documentation
Support
Need help with the API?- Join our Discord community
- Email us at support@braintrust.dev