| Crates.io | baml-sys |
| lib.rs | baml-sys |
| version | 0.218.0 |
| created_at | 2026-01-07 06:36:02.467811+00 |
| updated_at | 2026-01-22 08:59:57.484861+00 |
| description | BAML FFI bindings with runtime dynamic library loading |
| homepage | https://github.com/BoundaryML/baml |
| repository | https://github.com/BoundaryML/baml |
| max_upload_size | |
| id | 2027628 |
| size | 57,623 |
Low-level FFI bindings to the BAML runtime library with runtime dynamic loading.
This crate provides the FFI bindings to libbaml_cffi, the C FFI interface to the BAML runtime.
Unlike traditional -sys crates that link at compile time, baml-sys loads the library
dynamically at runtime using libloading.
The library is searched in the following order:
baml_sys::set_library_path() before first useBAML_LIBRARY_PATH~/.cache/baml/libs/{VERSION}/ (Linux), ~/Library/Caches/baml/libs/{VERSION}/ (macOS), %LOCALAPPDATA%\baml\libs\{VERSION}\ (Windows)download feature enabled)/usr/local/lib/, etc.use baml_sys::version;
fn main() -> Result<(), baml_sys::BamlSysError> {
// Library is loaded on first access
let v = version()?;
println!("BAML version: {v}");
Ok(())
}
In your build.rs:
fn main() {
// Ensure library is available before build completes
let lib_path = baml_sys::ensure_library()
.expect("Failed to find/download BAML library");
println!("cargo:rerun-if-changed={}", lib_path.display());
}
BAML_LIBRARY_PATH - Explicit path to the library fileBAML_CACHE_DIR - Override the cache directory locationBAML_LIBRARY_DISABLE_DOWNLOAD - Set to "true" to disable auto-downloaddownload (default) - Enable automatic download from GitHub releasesno-download - Disable download functionality