Skip to main content
Applies to:
  • Plan -
  • Deployment -

Summary

Issue: Downloading JSON exports for large experiments from the Braintrust UI fails with a malloc of size 1073741824 failed error or times out during the download process. Cause: The UI attempts to load the entire dataset into memory at once, causing memory allocation failures for experiments with thousands of records. Resolution: Use the Braintrust API or SDK to paginate and export large experiment data programmatically.

Resolution Steps

Pick the option that matches what you have on hand. If you copied an experiment ID out of the app URL, use Option 1 or 2. If you know the project and experiment names instead, Option 3 requires less setup.

Option 1: Export by experiment ID (Python)

Step 1: Install the API client

The REST client ships separately from the tracing SDK:

Step 2: Create the export script

Each fetch response returns a cursor. Pass it to the next request to walk through the experiment a page at a time.
limit caps the number of full traces per page, not the number of rows. A page containing multi-span traces will return more rows than limit.

Step 3: Run the script

Execute the script to generate experiment_data.json in your current directory.

Option 2: Export by experiment ID (TypeScript/JavaScript)

Step 1: Install the API client

Step 2: Create the export script

Step 3: Run the script

Execute the script to generate experiment_data.json in your current directory.

Option 3: Export by experiment name (Python tracing SDK)

If you already depend on the braintrust package, open the experiment in read-only mode with open=True and iterate it. fetch() paginates internally, so there is no cursor to manage.
open=True requires the experiment name, not its ID, and raises ValueError if the experiment does not already exist. Use Option 1 if all you have is an ID.

Option 4: Export to CSV format

Experiment events do not share a uniform set of keys, so make one paginated pass to collect the header fields, then make a second paginated pass to stream rows into the CSV. The script serializes nested values as JSON strings.

Additional Notes

A feature request exists to improve UI performance for large experiment downloads, including async export with email notification when ready. Until implemented, API-based exports are the recommended approach for datasets with more than 1000 records.