Skip to navigation

retry_policy

A retry policy can be attached to any client<llm> and will attempt to retry requests that fail due to a network error.

BAML
retry_policy MyPolicyName {
max_retries 3
}

Usage:

BAML
client<llm> MyClient {
provider anthropic
retry_policy MyPolicyName
options {
model "claude-sonnet-4-20250514"
api_key env.ANTHROPIC_API_KEY
}
}

Fields

max_retries
intRequired

Number of additional retries to attempt after the initial request fails.

strategy
Strategy

The strategy to use for retrying requests. Default is constant_delay(delay_ms=200).

StrategyDocsNotes
constant_delayDocs
exponential_backoffDocs

Example:

BAML
retry_policy MyPolicyName {
max_retries 3
strategy {
type constant_delay
delay_ms 200
}
}

Strategies

constant_delay

type
constant_delayRequired

Configures to the constant delay strategy.

delay_ms
int

The delay in milliseconds to wait between retries. Default: 200

exponential_backoff

type
exponential_backoffRequired

Configures to the exponential backoff strategy.

delay_ms
int

The initial delay in milliseconds to wait between retries. Default: 200

multiplier
float

The multiplier to apply to the delay after each retry. Default: 1.5

max_delay_ms
int

The maximum delay in milliseconds to wait between retries. Default: 10000