For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Help on Discord
HomeGuideExamplesBAML ReferencePlaygroundAgents.mdChangelog
HomeGuideExamplesBAML ReferencePlaygroundAgents.mdChangelog
    • Overview
  • baml-cli
    • init
    • generate
    • test
    • serve
    • dev
    • fmt
  • Language Reference
      • comments
      • Environment Variables
      • string
      • int / float
      • bool
      • array (list)
      • map (dictionary)
      • image / audio
    • Types
    • function
    • test
    • template_string
    • client<llm>
    • class
    • enum
    • generator
  • Generated baml_client
    • with_options(..)
    • AbortSignal / Cancellation
    • Collector
    • logging / env vars
    • AsyncClient / SyncClient
    • TypeBuilder
    • ClientRegistry
    • client Option
    • OnTick
    • Multimodal
    • Image
    • Audio
    • Pdf
    • Video
  • Attributes
    • What are attributes?
    • @alias / @@alias
    • @description / @@description
    • @skip
    • @assert
    • @check
    • Jinja in Attributes
    • @@dynamic
  • LLM Client Providers
    • Overview
    • AWS Bedrock
    • Anthropic
    • Google AI: Gemini
    • Google: Vertex
    • OpenAI
    • OpenAI Responses API
    • OpenAI from Azure
    • OpenRouter
    • openai-generic
    • Microsoft Foundry (openai-generic)
    • Cerebras (openai-generic)
    • Groq (openai-generic)
    • Hugging Face (openai-generic)
    • Keywords AI (openai-generic)
    • Llama API (openai-generic)
    • Litellm (openai-generic)
    • LM Studio (openai-generic)
    • Ollama (openai-generic)
    • Vercel AI Gateway (openai-generic)
    • Tinfoil (openai-generic)
    • TogetherAI (openai-generic)
    • Unify AI (openai-generic)
    • vLLM (openai-generic)
  • LLM Client Strategies
    • Timeout Configuration
    • Retry Policy
    • Fallback
    • Round Robin
  • Prompt Syntax
    • What is jinja?
    • Jinja Filters
    • ctx.output_format
    • ctx.client
    • _.role
    • Variables
    • Conditionals
    • Loops
  • Editor Extension Settings
    • baml.cliPath
    • baml.generateCodeOnSave
    • baml.enablePlaygroundProxy
    • baml.syncExtensionToGeneratorVersion
Help on Discord
LogoLogo
On this page
  • Syntax
  • Key Points:
  • Usage Examples
  • Example 1: Simple Array
  • Example 2: Multi-line Array
Language ReferenceGeneral BAML Syntax

array (list)

Was this page helpful?
Edit this page
Previous

map (dictionary)

Next
Built with

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:

1{
2 key1 [value1, value2, value3],
3 key2 [
4 value1,
5 value2,
6 value3
7 ],
8 key3 [
9 {
10 subkey1 "valueA",
11 subkey2 "valueB"
12 },
13 {
14 subkey1 "valueC",
15 subkey2 "valueD"
16 }
17 ]
18}

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

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

Example 2: Multi-line Array

1test CityDescription {
2 functions [DescriptionGame]
3 args { items [
4 "New York",
5 "Los Angeles",
6 "Chicago"
7 ]
8 }
9}