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
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
:
main.go