Skip to main content
Load balancing distributes traffic across multiple targets according to configured weights. This lets you spread load across API keys to stay within rate limits, A/B test providers, or maintain redundancy without hard failover.

Basic configuration

Set strategy.mode to "loadbalance" and assign a weight to each target. Weights are normalized, so 0.7 and 0.3 work the same as 7 and 3.
In this example, roughly 70% of requests go to OpenAI and 30% go to Anthropic.

Load balancing across API keys

Distribute requests across multiple API keys for the same provider to stay under per-key rate limits:
Equal weights result in round-robin-like distribution.

Load balancing across models

You can also distribute traffic across different models on the same provider:

Combining load balancing with fallbacks

Nest targets to get both load balancing and automatic failover. Each load-balanced target can itself be a fallback group:
70% of traffic goes to the OpenAI/Azure fallback group, and 30% goes directly to Anthropic.

Response headers

The gateway reports which target handled the request:
Weight selection is probabilistic, not strictly proportional per-request. Over a large number of requests, the distribution will converge to the configured weights.