fern/03-reference/baml/map.mdx
Map values (AKA Dictionaries) allow you to store key-value pairs.
<Tip>Most of BAML (clients, tests, classes, etc) is represented as a map.</Tip>
To declare a map in a BAML file, you can use the following syntax:
{
key1 value1,
key2 {
nestedKey1 nestedValue1,
nestedKey2 nestedValue2
}
}
class Person {
name string
age int
isEmployed bool
}
function DescribePerson(person: Person) -> string {
client "openai/gpt-5-mini"
prompt #"
Describe the person with the following details: {{ person }}.
"#
}
test PersonDescription {
functions [DescribePerson]
args {
person {
name "John Doe",
age 30,
isEmployed true
}
}
}
class Company {
name string
location map<string, string>
employeeCount int
}
function DescribeCompany(company: Company) -> string {
client "openai/gpt-5-mini"
prompt #"
Describe the company with the following details: {{ company }}.
"#
}
test CompanyDescription {
functions [DescribeCompany]
args {
company {
name "TechCorp",
location {
city "San Francisco",
state "California"
},
employeeCount 500
}
}
}
class Project {
title string
description string
}
function DescribeProject(project: Project) -> string {
client "openai/gpt-5-mini"
prompt #"
Describe the project with the following details: {{ project }}.
"#
}
test ProjectDescription {
functions [DescribeProject]
args {
project {
title "AI Research",
description #"
This project focuses on developing
advanced AI algorithms to improve
machine learning capabilities.
"#
}
}
}