BAML with Python/TS/Ruby

Calling BAML Functions

Once you’ve generated the BAML client and set your environment variables, you can call BAML functions from your code.

You can check out more examples in the BAML Examples repo.

We’ll use function ClassifyMessage(input: string) -> Category for our example:

BAML will generate b.ClassifyMessage() for you, which you can use like so:
1import asyncio
3from baml_client import b
4from baml_client.types import Category
6async def main():
7 category = await b.ClassifyMessage("I want to cancel my order")
8 print(category)
9 assert category == Category.CancelOrder
11if __name__ == '__main__':