Skip to main content

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​

OptionTypeRequiredDefaultDescription
strategyList[string]Yes-Client names to rotate through
startintNorandomStarting 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:

  1. First attempt: ClientA
  2. Retry 1: ClientB
  3. 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:

  1. MyClient(ClientA)
  2. ClientD
  3. ClientE
  4. MyClient(ClientB)
  5. ClientD
  6. ClientE
  7. MyClient(ClientC)
  8. ...

See Also​