Upload attachments
You can upload attachments from either your code or the UI. Your files are securely stored in an object store and associated with the uploading user’s organization. Only you can access your attachments.Via code
To upload an attachment, create a newAttachment object to represent the file path or in-memory buffer that you want to upload:
Attachment anywhere in a log, dataset, or feedback log.
Behind the scenes, the Braintrust SDK automatically detects and uploads attachments in the background, in parallel to the original logs. This ensures that the latency of your logs isn’t affected by any additional processing.
Use external files as attachments
The
ExternalAttachment feature is supported only in self-hosted deployments. It is not supported in Braintrust-hosted environments.ExternalAttachment object. You can use this anywhere you would use an Attachment. Currently S3 is the only supported option for external files.
JSON attachments
For large JSON objects that would bloat your trace size, you can useJSONAttachment. This is particularly useful for:
- Lengthy conversation transcripts
- Extensive document collections or knowledge bases
- Complex nested data structures with embeddings
- Large evaluation datasets
- Any JSON data that exceeds the 6MB trace limit
JSONAttachment automatically serializes your JSON data and stores it as an attachment with content type application/json. The data is:
- Uploaded separately as an attachment, bypassing the 6MB trace limit
- Not indexed, which saves storage space and speeds up ingestion
- Still fully viewable in the UI with all the features of the JSON viewer (collapsible nodes, syntax highlighting, search, etc.)
Upload attachments in the UI
You can upload attachments directly through the UI for any editable span field. This includes:- Any dataset fields, including datasets in playgrounds
- Log span fields
- Experiment span fields
Inline attachments
Sometimes your attachments are pre-hosted files which you do not want to upload explicitly, but would like to display as if they were attachments. Inline attachments allow you to do this, by specifying the URL and content type of the file. Create a JSON object anywhere in the log data withtype: "inline_attachment" and src and
content_type fields. The filename field is optional.

View attachments in the UI
You can preview images, audio files, videos, PDFs, and JSON files in the Braintrust UI. You can also download any file to view it locally. We provide built-in support to preview attachments directly in playground input cells and traces. In the playground, you can preview attachments in an inline embedded view for easy visual verification during experimentation:

Read attachments via SDK
You can programmatically read and process attachments using the Braintrust SDK. This allows you to access attachment data in your code for analysis, processing, or integration with other systems. When accessing a dataset or experiment, the TypeScript and Python SDKs automatically create aReadonlyAttachment object for each attachment.
For attachments in scorers or logs, use the ReadonlyAttachment class to access attachment data, check metadata, and process different content types.