Skip to main content

Generated Client

BAML generates both synchronous and asynchronous client SDKs for calling your BAML functions from Python, TypeScript, Go, and Ruby.

Basic Usage​

from baml_client import b
from baml_client.async_client import b as async_b

# Sync client
result = b.MyFunction("input")

# Async client
result = await async_b.MyFunction("input")

Call Patterns​

The generated client provides several call patterns:

PatternDescription
b.Function()Standard function call
b.stream.Function()Streaming response
b.request.Function()Get raw HTTP request without sending
b.stream_request.Function()Get streaming HTTP request
b.parse.Function()Parse raw LLM response
b.parse_stream.Function()Parse streaming response

Configuration Options​

Pass options to customize function calls:

OptionDescription
clientOverride the LLM client
collectorTrack usage and logs
client_registryUse custom client registry
type_builderDynamic type modifications
tagsAttach metadata to calls
abort_controllerCancel in-flight requests
on_tickReal-time progress callbacks