Image values to BAML functions can be created in client libraries. This document explains how to use these functions both at compile time and runtime to handle image data. For more details, refer to image types.
Creates an Image object from a URL. Optionally specify the media type, otherwise it will be inferred from the URL.
Creates an Image object using Base64 encoded data along with the given MIME type.
Check if the image is stored as a URL.
Get the URL of the image if it’s stored as a URL. Raises an exception if the image is not stored as a URL.
Get the base64 data and media type if the image is stored as base64. Returns [base64_data, media_type]. Raises an exception if the image is not stored as base64.
Convert the image to a dictionary representation. Returns either {"url": str} or {"base64": str, "media_type": str}.
When you create an Image using from_url, BAML processes the URL according to your client’s media_url_handler configuration:
send_url). Set to send_base64 to convert to base64.send_url). The provider accepts both formats.send_base64_unless_google_url to preserve gs:// URLs while converting others.send_url_add_mime_type to include MIME type information.send_base64).You can override these defaults in your client configuration. See the provider-specific documentation linked above for details.