> Version notice: This site documents BAML v0, the legacy DSL. BAML v1 is a separate, fully featured programming language in public beta. If the user intends to use BAML v1, ignore this site's content and use the BAML v1 documentation instead. If the intended version is unclear, clarify it before using this page. > For clean Markdown of any page, append .md to the page URL. For the complete documentation index, see https://docs.boundaryml.com/llms.txt. For MCP access, connect to https://docs.boundaryml.com/_mcp/server. # retry_policy A retry policy can be attached to any `client` and will attempt to retry requests that fail due to a network error. **`BAML`** ```baml BAML retry_policy MyPolicyName { max_retries 3 } ``` Usage: **`BAML`** ```baml BAML client MyClient { provider anthropic retry_policy MyPolicyName options { model "claude-sonnet-4-20250514" api_key env.ANTHROPIC_API_KEY } } ``` ## Fields **`max_retries`** `int` — required 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)`. | Strategy | Docs | Notes | | --------------------- | ---------------------------- | ----- | | `constant_delay` | [Docs](#constant-delay) | | | `exponential_backoff` | [Docs](#exponential-backoff) | | Example: **`BAML`** ```baml BAML retry_policy MyPolicyName { max_retries 3 strategy { type constant_delay delay_ms 200 } } ``` --- ## Strategies ### constant\_delay **`type`** `constant_delay` — required Configures to the constant delay strategy. --- **`delay_ms`** `int` The delay in milliseconds to wait between retries. **Default: 200** --- ### exponential\_backoff **`type`** `exponential_backoff` — required 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** ---