AI Gateway: Model Load Balancing Policy
The new AI Gateway Model Load Balancing policy spreads an app’s requests across a list of models. Use it to combine the rate limits of several deployments of the same model, to serve one model from more than one provider, or to split traffic across different models.
- Two strategies: Cycle through the list, or keep requests that share a key on the same model
- Built-in retry: Each request gets a retry model from the list for when the chosen model stays rate limited or fails
- Endpoint-aware: Models that can’t serve the request’s endpoint are skipped
Set a list for completions, which covers Chat Completions, Responses,
Messages, and System One requests, for embeddings, or for both. Each list
holds up to 32 models as providerName/model.
Round robin and sticky routing
round-robin, the default, gives every model in the list an equal share of
requests. sticky sends every request with the same key to the same model, on
every gateway instance, with no shared state. Choose the key with stickyBy:
user: The authenticated caller. With app API keys, that’s the app. On the User App, it’s the person who owns the personal key.conversation: The system prompt and first user message, so each conversation stays on the account whose prompt cache already holds it.expression: A value you select from the request, such as an end-user ID header, using the same expression syntax as metering budgets.
Adding or removing a model moves only the keys that model wins or loses. Every other key stays where it was.
Retries on another model
The retry model is the one the strategy would pick next. When the chosen model
keeps returning 429 after the gateway’s standard retries, the request moves
there. On chat completions and embeddings, a server error, an unreachable model,
or no response within fallbackTimeoutSeconds (60 seconds by default) moves it
too. Once a model starts streaming, the request stays on that model.
A stored Responses API response lives on the account that created it. Requests
that read or continue one go to that account when every model that stores
responses shares a provider name, or when sticky routing by user or
expression picks it.
Getting started
The policy is part of the AI Gateway template. Add it to an app on the app’s
Policies tab, set its model list, and place it after authentication and
before Fallback Model and Semantic Cache. Gateways connected to source control
can add the declaration with zuplo source upgrade --type ai-gateway. The
Model Load Balancing policy
documentation covers every option, which endpoints each provider can serve, and
how the policy works with Fallback Model and Smart Router.