array (list)

Allow you to store and manipulate collections of data. They can be declared in a concise and readable manner, supporting both single-line and multi-line formats.

Syntax

To declare an array in a BAML file, you can use the following syntax:

{
key1 [value1, value2, value3],
key2 [
value1,
value2,
value3
],
key3 [
{
subkey1 "valueA",
subkey2 "valueB"
},
{
subkey1 "valueC",
subkey2 "valueD"
}
]
}

Key Points:

  • Commas: Optional for multi-line arrays, but recommended for clarity.
  • Nested Arrays: Supported, allowing complex data structures.
  • Key-Value Pairs: Arrays can contain objects with key-value pairs.

Usage Examples

Example 1: Simple Array

function DescriptionGame(items: string[]) -> string {
client "openai/gpt-5-mini"
prompt #"
What 3 words best describe all of these: {{ items }}.
"#
}
test FruitList {
functions [DescriptionGame]
args { items ["apple", "banana", "cherry"] }
}

Example 2: Multi-line Array

test CityDescription {
functions [DescriptionGame]
args { items [
"New York",
"Los Angeles",
"Chicago"
]
}
}