baml-cli generate, you can call your BAML functions directly from your application code.
Basic Function Calls
Async Client
The async client is recommended for most use cases as it doesn’t block your application while waiting for LLM responses.- Python
- TypeScript
- Go
- Ruby
Sync Client
The sync client blocks execution until the LLM response is received. Use this when you need synchronous behavior or don’t have an async runtime.- Python
- TypeScript
- Go
- Ruby
Function Signature
Given a BAML function:- Python
- TypeScript
- Go
- Ruby
Advanced Call Patterns
Request Inspection
The.request object returns the raw HTTP request without sending it. Useful for debugging or custom request handling.
- Python
- TypeScript
- Ruby
Response Parsing
The.parse object parses LLM responses without making the actual API call. Use this with .request for full control.
- Python
- TypeScript
Type Safety
All generated functions are fully type-safe:- Python
- TypeScript
- Go
Error Handling
All BAML function calls can throw errors. See the Error Types page for details.- Python
- TypeScript
- Go
Related
- Streaming API - Stream responses as they’re generated
- Client Options - Configure function calls with options
- Error Types - Handle different error scenarios