BamlCallOptions
All BAML functions accept options as their final parameter:- Python
- TypeScript
- Go
- Ruby
Option Reference
client
Type: string
Override which LLM client to use for this call. Supports:
- Shorthand syntax:
"provider/model"(e.g.,"openai/gpt-4o","anthropic/claude-sonnet-4-20250514") - Named client: Reference a client defined in your
.bamlfiles
- Python
- TypeScript
- Go
client_registry
Type: ClientRegistry
Provide a custom client registry for advanced client configuration. Allows you to:
- Add new LLM clients at runtime
- Override client settings
- Set a primary client
- Python
- TypeScript
- Go
client and client_registry are provided, client takes precedence.
collector
Type: Collector | Collector[]
Attach collectors to track and analyze function execution. Collectors capture:
- Function inputs and outputs
- Prompts and LLM responses
- Token usage
- Latency metrics
- Python
- TypeScript
- Go
env
Type: Record<string, string | undefined>
Override environment variables for this specific call. Useful for:
- Using different API keys
- Testing with different configurations
- Multi-tenant applications
- Python
- TypeScript
- Go
tags
Type: Record<string, string>
Add metadata tags to function calls for filtering and analysis in observability tools.
- Python
- TypeScript
- Go
on_tick
Type: (reason: string, log: FunctionLog | null) => void
Receive real-time callbacks during function execution. Useful for:
- Monitoring progress
- Debugging
- Accessing streaming metadata
- Python
- TypeScript
- Go
signal (TypeScript only)
Type: AbortSignal
Cancel function execution using an abort controller.
tb (TypeBuilder)
Type: TypeBuilder
Dynamically modify types at runtime. Advanced feature for dynamic schema generation.
- Python
- TypeScript
Using with_options / withOptions
Set default options for multiple function calls:
- Python
- TypeScript
- Ruby
Default Values
| Option | Default |
|---|---|
client | Client specified in BAML function |
client_registry | None / null |
collector | None / null |
env | Process environment variables |
tags | {} (empty) |
on_tick | None / null |
signal | undefined |
tb | None / null |
Related
- Calling Functions - Basic function call API
- Calling Functions - Basic function call API
- Streaming API - Streaming responses
- Collectors - Track function execution
- Error Types - Handle errors