Installation Steps
Install BAML VSCode/Cursor Extension
Install the extension from: https://marketplace.visualstudio.com/items?itemName=boundary.baml-extensionFeatures include:
- Syntax highlighting
- Testing playground
- Prompt previews
Install BAML CLI and Initialize Project
Install the BAML CLI tool globally and create starter BAML code:This will:
- Install the BAML CLI tool globally
- Create starter BAML code in a
baml_srcdirectory - Set up the basic project structure
Install Required Go Tools
The BAML generator uses These tools are required by the
gofmt and goimports to format generated code:on_generate command in your generator configuration.Generate the baml_client Package
One of the files in your Any types defined in
baml_src directory will have a generator block. Run this command to auto-generate the baml_client directory with Go code:.baml files will be converted into Go structs.Build Integration
You can modify your build process to always callbaml-cli generate before building:
Makefile
Working with Go Modules
BAML integrates seamlessly with Go modules. Ensure yourgo.mod includes the BAML dependency:
go.mod
baml_client package uses your module path:
Context and Cancellation
All BAML Go functions require acontext.Context as the first parameter: