Image / Audio
Image / Audio values to BAML functions can by created in client libraries. This document explains how to use these functions both at compile time and runtime to handle multimedia data. For more details, refer to image types and audio types.
Images
BAML functions that accept an image input utilize the Image helper, which supports creating Image objects from URLs or Base64 encoded data.
Image Creation Methods
• Image.from_url(url: string, media_type: string | null)
: Creates an Image object from the specified URL. (optionally specify the media type, otherwise it will be inferred from the URL)
• Image.from_base64(mime_type: string, data: string)
: Creates an Image object using Base64 encoded data along with the given MIME type.
Usage
Audio
BAML functions that accept audio inputs utilize the Audio helper. Similar to images, you can create Audio objects from URLs or Base64 encoded data.
Audio Creation Methods
• Audio.from_url(url: string): Creates an Audio object from the specified URL.
• Audio.from_base64(mime_type: string, data: string): Creates an Audio object using Base64 encoded audio data with the provided MIME type.
Usage
Python
TypeScript
Ruby (beta)