REST API (other languages)
Requires BAML version >=0.55
BAML allows you to expose your BAML functions as RESTful APIs:

We integrate with OpenAPI (universal API definitions), so you can get typesafe client libraries for free!
Install BAML VSCode Extension
https://marketplace.visualstudio.com/items?itemName=boundary.baml-extension
- syntax highlighting
- testing playground
- prompt previews
Add BAML to your existing project
This will give you some starter BAML code in a baml_src
directory.
C#
C++
Go
Java
PHP
Ruby
Rust
Other
Start the BAML development server
This will do four things:
- serve your BAML functions over a RESTful interface on
localhost:2024
- generate an OpenAPI schema in
baml_client/openapi.yaml
- run
openapi-generator -g $OPENAPI_CLIENT_TYPE
inbaml_client
directory to generate an OpenAPI client for you to use - re-run the above steps whenever you modify any
.baml
files
Check that the server is running
After running the npx @boundaryml/baml dev
command, you can check that the
server is up and running by making an HTTP request to these routes:
-
http://localhost:2024/_debug/ping
: Open in the browser or usecurl
to check that the server is up. You should see a text response similar to this:pong (from baml v0.206.1)
. -
http://localhost:2024/docs
: Open in the browser to see and interact with all your routes through the Swagger UI generated from the OpenAPI schema.
If using Docker, replace localhost
with the container hostname or IP as
appropriate.
Use a BAML function in any language!
openapi-generator
will generate a README
with instructions for installing
and using your client; we’ve included snippets for some of the most popular
languages below. Check out
baml-examples
for example
projects with instructions for running them.
Go
Java
PHP
Ruby
Rust
Run this with go run main.go
: