Models fail. Rate limits hit. BAML handles this declaratively—no try/catch spaghetti.
Define retry policies and fallback chains. Swap models without touching your functions.
retry_policy Resilient {
max_retries 3
strategy {
type exponential_backoff
initial_delay_ms 500
max_delay_ms 10000
}
}
client<llm> ReliableGPT {
provider openai
options {
model "gpt-4o-mini"
api_key env.OPENAI_API_KEY
}
retry_policy Resilient
}
client<llm> FallbackChain {
provider "baml-fallback"
options {
strategy [
ReliableGPT,
{ provider anthropic, options { model "claude-3-haiku-20240307" } }
]
}
}