Customize the webapp URL
The SDKs guide users tohttps://www.braintrust.dev (or the BRAINTRUST_APP_URL variable) to view their experiments. In some
advanced configurations, you can reverse proxy traffic to the BRAINTRUST_APP_URL from the SDKs while pointing users
to a different URL.
To do this, you can set the BRAINTRUST_APP_PUBLIC_URL environment variable to the URL of your webapp. By default, this variable is set to
the value of BRAINTRUST_APP_URL, but you can customize it as you wish. This variable is only used to display information, so even its destination
does not need to be accessible from the SDK.
Constrain SDKs to the data plane
If you’re self-hosting the data plane, you can also constrain the SDKs to only communicate with your data plane. Normally, they communicate with the control plane to:- Get your data plane’s URL
- Register and retrieve metadata (e.g. about experiments)
- Print URLs to the webapp
BRAINTRUST_APP_URL environment variable to the URL of your data plane and BRAINTRUST_APP_PUBLIC_URL to “https://www.braintrust.dev”
(or the URL of your webapp).
Restrict URLs
To restrict the URLs that the SDKs or API server can communicate with, include the following URLs:Configure rate limits
By default, the Braintrust API server imposes rate limits against any external domains it reaches out to, such as theBRAINTRUST_APP_URL. The purpose of
rate-limiting is to prevent unintentionally overloading any external domains,
which may block the API server IP in response.
By default, the rate limit is 100 requests per minute per user auth token. The
API server exposes the following variables to configure the rate limits:
OUTBOUND_RATE_LIMIT_MAX_REQUESTS: Configure the number of requests per time window. This can be set to 0 to disable rate limiting.OUTBOUND_RATE_LIMIT_WINDOW_MINUTES: Configure the time window in minutes before the rate limit resets.
Configure HTTP keep-alive timeout
When the API server runs behind a load balancer, you may need to configure the HTTP keep-alive timeout to prevent connection resets. Load balancers typically have an idle timeout for connections, and if the API server’s keep-alive timeout is shorter than the load balancer’s timeout, the API server closes the connection while the load balancer still considers it open. When the load balancer tries to reuse that backend connection, it encounters a closed socket, resulting in connection reset errors and 502 responses. The API server exposes the following environment variable to configure the keep-alive timeout:TS_API_KEEP_ALIVE_TIMEOUT_SECONDS: The HTTP keep-alive timeout in seconds. Default:65
Configure CloudFront origin timeout
On AWS, requests are served through CloudFront, which closes a connection and returns504 Gateway Timeout if the origin takes too long to respond. Long-running scorers or tools invoked through /function/invoke can exceed the default 60-second origin read timeout. Raise it with the cloudfront_origin_read_timeout Terraform variable (available in Terraform module v5.3.0 or later):
Configure API ALB HTTPS
On AWS with the ECS API, an internal Application Load Balancer (ALB) fronts the API services. By default, the ALB serves plain HTTP on port 80 using its AWS-assigned DNS name. To serve HTTPS on a custom domain instead, set bothbraintrust_api_alb_certificate_arn and braintrust_api_alb_custom_domain (available in Terraform module v6.0.0 or later):
https://<braintrust_api_alb_custom_domain>. The certificate must cover the custom domain, and the domain must resolve to the ALB.
These two variables must both be set or both be null. Setting only one fails at plan time.
VPC connectivity
On AWS, to connect Braintrust’s VPC to other internal resources (like an LLM gateway), use one of the following approaches:- Create a VPC Endpoint Service for your internal resource, then create a VPC Interface Endpoint inside the Braintrust “Quarantine” VPC.
- Set up VPC peering with the Braintrust “Quarantine” VPC.