What is BAML?

The best way to understand BAML and its developer experience is to see it live in a demo (see below).

Demo video

Here we write a BAML function definition, and then call it from a Python script.

Examples

High-level Developer Flow

1

Write a BAML function definition

main.baml
class WeatherAPI {
city string @description("the user's city")
timeOfDay string @description("As an ISO8601 timestamp")
}
function UseTool(user_message: string) -> WeatherAPI {
client "openai-responses/gpt-5-mini"
prompt #"
Extract.... {# we will explain the rest in the guides #}
"#
}

Here you can run tests in the VSCode Playground.

2

Generate baml_client from those .baml files.

This is auto-generated code with all boilerplate to call the LLM endpoint, parse the output, fix broken JSON, and handle errors.

3

Call your function in any language

with type-safety, autocomplete, retry-logic, robust JSON parsing, etc..

import asyncio
from baml_client import b
from baml_client.types import WeatherAPI
def main():
weather_info = b.UseTool("What's the weather like in San Francisco?")
print(weather_info)
assert isinstance(weather_info, WeatherAPI)
print(f"City: {weather_info.city}")
print(f"Time of Day: {weather_info.timeOfDay}")
if __name__ == '__main__':
main()

Continue on to the Installation Guides for your language to setup BAML in a few minutes!

You don’t need to migrate 100% of your LLM code to BAML in one go! It works along-side any existing LLM framework.