When you develop with BAML, the BAML VSCode extension generates aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/BoundaryML/baml/llms.txt
Use this file to discover all available pages before exploring further.
baml_client directory (on every save) with all the generated code you need to use your AI functions in your application.
We recommend you add baml_client to your .gitignore file to avoid committing generated code to your repository, and re-generate the client code when you build and deploy your application.
Generating the BAML Client
To build your client in a Docker container, use thebaml-cli generate command. See also baml-cli generate.
Go: Multi-stage Docker Builds
When using Go, thebaml-cli generate command downloads the libbaml-cffi native library that BAML needs at runtime. This library is cached to avoid downloading it every time your container runs.
Single-stage Builds
For single-stage builds, runningbaml-cli generate (as shown above) will automatically download and cache libbaml-cffi in your Docker image.
Multi-stage Builds
For multi-stage Docker builds, you need to ensurelibbaml-cffi is available in your final image. You have two options:
Option 1: Copy the Cache Directory
Set the BAML_CACHE_DIR environment variable in both stages and copy it to your final image:
baml-cli in your final image and run baml-cli --version (or baml-cli generate) to download libbaml-cffi:
Customizing the Cache Directory
By default, BAML downloadslibbaml-cffi to a system-specific cache directory. You can control this location using the BAML_CACHE_DIR environment variable:
BAML-over-HTTP with Docker
You can deploy BAML as a RESTful API using Docker. This is useful when you want to run BAML functions as a separate service.Creating the Dockerfile
In the directory containing yourbaml_src/ directory, create a baml.Dockerfile:
Running with Docker Compose
We recommend usingdocker-compose to run your app and BAML-over-HTTP side-by-side:
docker-compose.yaml
To call the BAML server from your laptop (i.e. the host machine), you must use
localhost:2024. You may only reach it as baml-over-http:2024 from within another Docker container.Securing Your BAML Server
You can set a password on the BAML server using theBAML_PASSWORD environment variable:
X-BAML-API-KEY header:
BAML_PASSWORD will secure all endpoints except /_debug/ping, so that you can always debug the reachability of your BAML server.