- 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 API is hosted globally at: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:
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 allows a privileged user to perform an operation on behalf of another user, using the impersonated user’s identity and permissions. For example, a proxy service may wish to forward requests coming in from individual users to Braintrust without requiring each user to directly specify Braintrust credentials. The privileged service can initiate the request with its own credentials and impersonate the user so that Braintrust runs the operation with the user’s permissions. To impersonate a user, set thex-bt-impersonate-user header to the ID or email of the user to impersonate. Currently impersonating another user requires that the requesting user has specifically been granted the Owner role over all organizations that the impersonated user belongs to. This check guarantees the requesting user has at least the set of permissions that the impersonated user has.
The following examples show how to configure ACLs and run a request with 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
- Check the GitHub repository
- Email us at [email protected]