Install Canary, create a project, and run your first BAML function.
Run a BAML function from the terminal. This first example needs no model provider or API key.
Install the toolchain
Choose one installation method.
macOS or Linux
If you already use Homebrew:
Without Homebrew, run the installer in Bash or Zsh:
The installer adds BAML to your Bash or Zsh startup file. The second command makes baml available in the current terminal.
Windows
Run these commands in PowerShell:
The installer adds BAML to your user PATH. The last command makes it available in the current PowerShell session.
Arch Linux
If you use yay, install the AUR package:
Select Canary
These guides use Canary. Select it and download the latest toolchain:
Create a project
This creates baml.toml and baml_src/main.baml. Replace the contents of main.baml with:
return-number.bamlfunction return_number(value: int) -> int {
value
}function return_number(value: int) -> int {
value
}Check and run
The function returns 42. Put function arguments after --; use baml run return_number -- --help to see the accepted arguments.
Add editor support
Editor support is optional. With VS Code installed, run:
For Cursor:
For another VS Code-compatible editor, save the extension locally:
In your editor's Extensions view, choose Install from VSIX and select the downloaded .vsix file.
Set up a coding agent
If you use a coding agent, run this from the project root:
This installs the active toolchain's BAML skill for supported agents. Use baml describe to inspect available functions and types while you work.
Update BAML
To get the latest Canary toolchain:
To update the baml launcher itself, use brew upgrade baml for a Homebrew installation, yay -S baml-bin for an AUR installation, or baml self-update for a script installation.
Next steps
- Classify support tickets: call a model and get an enum value back.
- Work with images: mix images and text in a prompt.
- TypeScript bridge: call BAML from a Node.js application.
- The BAML book: learn errors, interfaces, and concurrency.