- 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:
You can find your API URL in Settings > Data plane.
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
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
- Organizations: Manage your organization settings
- Users: Manage team members
- Groups: Organize users into teams
- Project groups: Organize projects into groups
- Roles: Define permission levels
- ACLs: Configure fine-grained access control
- API keys: Manage authentication credentials
- Service tokens: Generate service-level authentication tokens
- 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 endpoint and are scoped to an organization, a project, or both. If you exceed the rate limit, you’ll receive a429 Too Many Requests response. See system limits for the limits that apply to all deployments, or Set inbound request rate limits to configure them on a self-hosted deployment.
Query data
Query your logs, experiments, and datasets with SQL through the/btql endpoint. For a full reference, see Query by SQL.
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:
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
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
To make API requests using another user’s identity and permissions, authenticate with a personal API key or service token and set thex-bt-impersonate-user header to the target user’s email or user ID.
Braintrust requires that:
- The authenticating user or service account must have the
Ownerrole in every organization the target user belongs to, through a direct role grant or membership in a permission group with that role. TheManage settingspermission alone is not sufficient. - The target user must belong to at least one organization.
BRAINTRUST_API_KEY to your personal API key or service token, and USER_EMAIL to the target user’s email. For self-hosted deployments, replace https://api.braintrust.dev with your deployment’s Universal API URL:
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