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 Map
  • Example 2: Nested Map
  • Example 3: Map with Multiline String
Language ReferenceGeneral BAML Syntax

map (dictionary)

Was this page helpful?
Edit this page
Previous

Image / Audio / Pdf / Video

Next
Built with

Map values (AKA Dictionaries) allow you to store key-value pairs.

Most of BAML (clients, tests, classes, etc) is represented as a map.

Syntax

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

1{
2 key1 value1,
3 key2 {
4 nestedKey1 nestedValue1,
5 nestedKey2 nestedValue2
6 }
7}

Key Points:

  • Colons: Not used in BAML maps; keys and values are separated by spaces.
  • Value Types: Maps can contain unquoted or quoted strings, booleans, numbers, and nested maps as values.
  • Classes: Classes in BAML are represented as maps with keys and values.

Usage Examples

Example 1: Simple Map

1class Person {
2 name string
3 age int
4 isEmployed bool
5}
6
7function DescribePerson(person: Person) -> string {
8 client "openai/gpt-5-mini"
9 prompt #"
10 Describe the person with the following details: {{ person }}.
11 "#
12}
13
14test PersonDescription {
15 functions [DescribePerson]
16 args {
17 person {
18 name "John Doe",
19 age 30,
20 isEmployed true
21 }
22 }
23}

Example 2: Nested Map

1class Company {
2 name string
3 location map<string, string>
4 employeeCount int
5}
6
7function DescribeCompany(company: Company) -> string {
8 client "openai/gpt-5-mini"
9 prompt #"
10 Describe the company with the following details: {{ company }}.
11 "#
12}
13
14test CompanyDescription {
15 functions [DescribeCompany]
16 args {
17 company {
18 name "TechCorp",
19 location {
20 city "San Francisco",
21 state "California"
22 },
23 employeeCount 500
24 }
25 }
26}

Example 3: Map with Multiline String

1class Project {
2 title string
3 description string
4}
5
6function DescribeProject(project: Project) -> string {
7 client "openai/gpt-5-mini"
8 prompt #"
9 Describe the project with the following details: {{ project }}.
10 "#
11}
12
13test ProjectDescription {
14 functions [DescribeProject]
15 args {
16 project {
17 title "AI Research",
18 description #"
19 This project focuses on developing
20 advanced AI algorithms to improve
21 machine learning capabilities.
22 "#
23 }
24 }
25}