Bitfab integrates with BAML to automatically capture rendered prompts and LLM metadata on the current span — no manualDocumentation Index
Fetch the complete documentation index at: https://docs.bitfab.ai/llms.txt
Use this file to discover all available pages before exploring further.
setPrompt or addContext calls needed. Wrap a BAML method with wrapBAML / wrap_baml and Bitfab extracts everything automatically.
Canonical signatures: TypeScript wrapBAML · Python wrap_baml
Supported Languages
| Language | Method | Status |
|---|---|---|
| TypeScript | wrapBAML() | ✅ Supported |
| Python | wrap_baml() | ✅ Supported |
| Ruby | — | Not yet supported |
| Go | — | Not yet supported |
Quick Start
What Gets Captured
wrapBAML / wrap_baml creates a BAML Collector, runs the method through a tracked client, then extracts:
| Data | Span Field | Source |
|---|---|---|
| Rendered prompt (system + user messages) | span_data.prompt | BAML Collector HTTP request body |
| Model name | span_data.contexts[].model | BAML Collector HTTP request body or URL |
| Provider | span_data.contexts[].provider | BAML Collector call metadata |
| Input tokens | span_data.contexts[].inputTokens | BAML Collector usage |
| Output tokens | span_data.contexts[].outputTokens | BAML Collector usage |
| Duration | span_data.contexts[].durationMs | BAML Collector timing |
@boundaryml/baml (TypeScript) or baml-py (Python) is not installed, the BAML method is called directly without instrumentation.
TypeScript
Installation
Method Signature
method(Function, required) — The BAML method to wrap (e.g.,b.ClassifyText)bamlClient(unknown, optional) — The BAML client instance. Required if not passed in theBitfabconstructoroptions(WrapBAMLOptions, optional) — Configuration options
onCollector?: (collector: unknown) => void— Callback fired after each invocation with the BAML Collector instance
WrappedBamlFn — an async function with the same signature as the original, plus a .collector property.
Usage
Constructor-Based (Recommended)
Explicit Client
Accessing the BAML Collector
The wrapped function exposes a.collector property containing the BAML Collector from the most recent call:
.collector is null before the first call or if @boundaryml/baml is not installed.
onCollector Callback
For more control, pass an onCollector callback:
Error Handling
If@boundaryml/baml is not installed, wrapBAML falls back to calling the method directly on the BAML client without instrumentation. Metadata extraction errors are silently caught.
Python
Installation
Method Signature
method(Callable, required) — The BAML method to wrap (e.g.,b.ClassifyText)baml_client(Any, optional) — The BAML client instance. Required if not passed in theBitfabconstructor
Usage
Constructor-Based (Recommended)
Explicit Client
Error Handling
Ifbaml-py is not installed, wrap_baml falls back to calling the method directly on the BAML client without instrumentation. Metadata extraction errors are silently caught.