Round Robin
The round-robin provider distributes requests across multiple clients in rotation.
Basic Example
client<llm> MyClient {
provider round-robin
options {
strategy [
ClientA
ClientB
ClientC
]
}
}
Calling MyClient multiple times: A → B → C → A → B → C → ...
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
strategy | List[string] | Yes | - | Client names to rotate through |
start | int | No | random | Starting index |
note
In the BAML Playground, start defaults to 0. In production, it defaults to a random value.
With Retry Policy
When using a retry policy, round-robin rotates the strategy list after each retry:
client<llm> MyClient {
provider round-robin
retry_policy MyRetryPolicy
options {
strategy [
ClientA
ClientB
ClientC
]
}
}
If ClientA fails and triggers retry:
- First attempt:
ClientA - Retry 1:
ClientB - Retry 2:
ClientC
Nesting Round Robin
Nested round-robin clients compose as expected:
client<llm> MyClient {
provider round-robin
options {
strategy [
ClientA
ClientB
ClientC
]
}
}
client<llm> MegaClient {
provider round-robin
options {
strategy [
MyClient
ClientD
ClientE
]
}
}
Calling MegaClient multiple times:
MyClient(ClientA)ClientDClientEMyClient(ClientB)ClientDClientEMyClient(ClientC)- ...