Media values as denoted more specifically in BAML.

Baml Type
image
audio

Both image and audio values values can be:

  • A URL
  • A base64 encoded string
  • A file path

For usage in Python / Typescript / etc, see baml_client > media.

Usage as a URL

1// Pass in an image type
2function DescribeImage(image: image) -> string {
3 client "openai/gpt-4o-mini"
4 prompt #"
5 Describe the image.
6 {{ image }}
7 "#
8}
9
10test ImageDescriptionFromURL {
11 functions [DescribeImage]
12 args {
13 image {
14 url "https://upload.wikimedia.org/wikipedia/en/4/4d/Shrek_%28character%29.png"
15 }
16 }
17}
18
19test ImageDescriptionFromBase64 {
20 functions [DescribeImage]
21 args {
22 image {
23 media_type "image/png"
24 base64 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x/AAzmH+UlvRkwAAAAASUVORK5CYII="
25 }
26 }
27}
28
29test ImageDescriptionFromFile {
30 functions [DescribeImage]
31 args {
32 image {
33 file "./shrek.png"
34 }
35 }
36}
Built with