What is baml_client?
baml_client is the code that gets generated from your BAML files that transforms your BAML prompts into the same equivalent function in your language, with validated type-safe outputs.
Python
This has all the boilerplate to:
- call the LLM endpoint with the right parameters,
- parse the output,
- fix broken JSON (if any)
- return the result in a nice typed object.
- handle errors
In Python, your BAML types get converted to Pydantic models. In Typescript, they get converted to TypeScript types, and so on. BAML acts like a universal type system that can be used in any language.
Generating baml_client
Refer to the Installation guides for how to set this up for your language, and how to generate it.
But at a high-level, you just include a generator block in any of your BAML files.
The baml_client
transforms a BAML function into the same equivalent function in your language,