- Reference media files via external URLs.
- Customize the handling of media files in the SDKs via the
ABVMediaclass. - Integrate via the ABV API directly.
Supported media formats
ABV supports:- Images: .png, .jpg, .webp
- Audio files: .mpeg, .mp3, .wav
- Other attachments: .pdf, plain text
Get Started
Base64 data URI encoded media
If you use base64 encoded images, audio, or other files in your LLM applications, upgrade to the latest version of the ABV SDKs. The ABV SDKs automatically detect and handle base64 encoded media by extracting it, uploading it separately as a ABV Media file, and including a reference in the trace. This works with standard Data URI (MDN) formatted media (like those used by OpenAI and other LLMs). For examples using the OpenAI SDK and LangChain, refer to the Python SDK instrumentation guide or JavaScript/TypeScript SDK instrumentation guide.External media (URLs)
ABV supports in-line rendering of media files via URLs if they follow common formats. In this case, the media file is not uploaded to ABV’s object storage but simply rendered in the UI directly from the source.Supported formats:
Markdown imagesCustom attachments
If you want to have more control or your media is not base64 encoded, you can upload arbitrary media attachments to ABV via the SDKs using the newABVMedia class. Wrap media with ABVMedia before including it in trace inputs, outputs, or metadata. See the multi-modal documentation for examples.
Python SDK
Install packageJS/TS SDK
Install packages.env file in your project root and a package like dotenv to load the variables.
Createinstrumentation.ts file and use dotenv package to load the variables.
Additional parameters are provided to get trace visible in the UI immediately.
Import the instrumentation.ts file at the top of your application.
API
If you use the API directly to log traces to ABV, you need to follow these steps:1) Upload media to ABV
- If you use base64 encoded media: you need to extract it from the trace payloads similar to how the ABV SDKs do it.
- Initialize the upload and get a
mediaIdandpresignedURL:POST /api/public/media. - Upload media file:
PUT [presignedURL].
2) Add reference to mediaId in trace/observation
Use the ABV Media Token to reference themediaId in the trace or observation input, output, or metadata.
How does it work?
When using media files (that are not referenced via external URLs), ABV handles them in the following way:1. Media Upload Process
Detection and Extraction
- ABV supports media files in traces and observations on
input,output, andmetadatafields - SDKs separate media from tracing data client-side for performance optimization
- Media files are uploaded directly to object storage (AWS S3 or compatible)
- Original media content is replaced with a reference string
Security and Optimization
- Uploads use presigned URLs with content validation (content length, content type, content SHA256 hash)
- Deduplication: Files are simply replaced by their
mediaIdreference string if already uploaded - File uniqueness determined by project, content type, and content SHA256 hash
Implementation Details
- Python SDK: Background thread handling for non-blocking execution
- JS/TS SDKs: Asynchronous, non-blocking implementation
- API support for direct uploads (see Public API documentation)
2. Media Reference System
The base64 data URIs and the wrappedABVMedia objects in ABV traces are replaced by references to the mediaId in the following standardized token format, which helps reconstruct the original payload if needed:
MIME_TYPE: MIME type of the media file, e.g.,image/jpegABV_MEDIA_ID: ID of the media file in ABV’s object storageSOURCE_TYPE: Source type of the media file, can bebase64_data_uri,bytes, orfile
mediaId and render the media file inline. The ABVMedia class provides utility functions to extract the mediaId from the reference string.
3. Resolving Media References
When dealing with traces, observations, ~~or ~~dataset items that include media references, you can convert them back to their base64 data URI format using theresolve_media_references utility method provided by the ABV client. This is particularly useful for reinserting the original content during fine-tuning, dataset runs, or replaying a generation. The utility method traverses the parsed object and returns a deep copy with all media reference strings replaced by the corresponding base64 data URI representations.