Sixteen days to Christmas Eve and the wish-list desk is buried in letters. Every one goes through a single provider key, and that key has started saying no.
- Ledger
Four hundred 429s in ten minutes. One key is pulling the whole sleigh, and it ran out of breath an hour ago.
- Rudolph
Tower, I count eight reindeer in the hangar and one flying every route solo. Requesting a split formation.
- Ledger
Seventy in every hundred letters to one provider, thirty to another. Can the router do that, or do I start a tally sheet?
- Tinsel
No tally sheet. One
load_balancer, two weights, and the router hitches each letter to one model by weight.
- clientYour app
- orq.aiAI Routerload_balancer · weight_based
- 70%30%weight 0.7openai/gpt-6-lunaweight 0.3google/gemini-4-neon
- responseOne reply
How it works
Tinsel’s fix is one more object in the request body. When the router gets a request with a load_balancer object:
- Rule check. If a Routing Rule with its own target models matches the request, the rule’s strategy and models replace your
model,load_balancerandfallbacksentirely. The two are never merged. - Pick one model. Otherwise the router picks exactly one model from
load_balancer.models, using the strategy inload_balancer.type. - Call it. The router sends the request to that model and returns its answer. If the call fails, it does not try another model in the pool.
The top-level model is only used as-is when the load balancer cannot pick, for example with an empty models list. Every entry needs a model and a weight between 0.001 and 1.0. Weights are normalised, so [0.4, 0.8] becomes 33% and 67%.
Try it with curl
curl -X POST https://my.orq.ai/v3/router/responses \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-6-luna",
"input": "Sort the wish lists",
"load_balancer": {
"type": "weight_based",
"models": [
{"model": "openai/gpt-6-luna", "weight": 0.7},
{"model": "google/gemini-4-neon", "weight": 0.3}
]
}
}'
Or from the OpenAI SDK
load_balancer is not part of the OpenAI request types, so pass it in extra_body. This one takes turns:
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["ORQ_API_KEY"],
base_url="https://my.orq.ai/v3/router",
)
response = client.responses.create(
model="openai/gpt-6-luna",
input="Sort the wish lists",
extra_body={
"load_balancer": {
"type": "round_robin",
"models": [
{"model": "openai/gpt-6-luna", "weight": 0.5},
{"model": "google/gemini-4-neon", "weight": 0.5},
],
}
},
)
print(response.output_text)
Pick a strategy
type |
How it picks | Use it when |
|---|---|---|
weight_based |
At random, in proportion to the weights | You want a fixed split: cost control, A/B tests |
round_robin |
The next model in the list, then wraps around | You want an equal share; weights are ignored |
latency_based |
The lowest recently observed latency | Response time matters more than the split |
latency_based uses samples from the last 5 minutes. Ten percent of selections still explore the whole pool by weight, to keep latency measurements fresh. Failed calls are penalised, so a fast failure does not look like a fast success. Expect it to send most traffic to one model once that model is consistently fastest. Latency history is kept in memory, so after a restart every model starts as unknown until fresh samples arrive.
Pair it with fallbacks
Load balancing spreads traffic. It does not rescue a failed call. Add fallbacks (door 7) in the same body for that:
{
"load_balancer": { "type": "weight_based", "models": [ ... ] },
"fallbacks": [{"model": "azure/gpt-6-sol"}]
}
You can also send retry and timeout next to load_balancer. You need API access to every model in the pool, and different models can answer with different quality, so balance between models you would be happy to ship.
Nice list
- Spread traffic across providers, not only models. Then one provider's outage hits only part of your traffic: the docs call this a smaller blast radius.
- Match the strategy to the goal:
weight_basedfor an uneven split such as cost control or an A/B test,round_robinfor an equal share,latency_basedwhen speed matters more. - Give a new model a small share first. The docs show 90/10 for an A/B test and 95/5 for trying a new model.
Naughty list
- Leaving
weightout onround_robinbecause it is ignored there. The field is still required for every model, so the pool is not valid without it. - Expecting the load balancer to fail over. It does not retry a failed call against another model in the pool.
- Judging a 70/30 split after ten calls. Ten calls can easily come out 5/5; the docs suggest at least 100 requests before you judge.
- Sending
load_balancerandfallbackswhile a Routing Rule with its own target models matches. The rule replaces both entirely.
Elf's challenge
Ledger flips the curl example to "type": "round_robin" but keeps the weights at 0.7 and 0.3, then bets that 14 of the next 20 letters go to gpt-6-luna. Should he take the bet?
Stuck? Ask Tinsel for a hint
No. Round robin takes the next model in the list and wraps back to the first, so weights do not count: expect an even split. You still have to send a weight for each model.
Christmas crackerWhy didn't the load balancer catch the present that fell off the sleigh?Pull it for the punchline
It doesn't do falls. That's what fallbacks are for.