Council, cascade and race
One request can use several models. Pick a plan by what you want to optimise.
| Plan | Models are asked | Good for | Answers get |
|---|---|---|---|
| Fallback chain | one at a time, until one answers | surviving outages and rate limits | - |
| Council | all at once, blended | fewer confident mistakes | agreement |
| Cascade | cheapest first, escalating only unsure questions | cost | answered_by |
| Race | all at once, first valid answer wins | latency | - |
Fallback chain
Section titled “Fallback chain”client.decide(state, questions, model=["model-a", "model-b"])If a model returns 429 or a server error, the next one takes over. The response’s model says
which one answered.
When no model can answer
Section titled “When no model can answer”A chain can still run out: every model failed or timed out, the rate limit held after the
retries, or the server can’t be reached. Give decide a fallback, one safe answer per
question, and it returns those instead of raising:
d = client.decide(ticket, questions, fallback={"team": "human_review", "refund": False})if d.fallback: # no model answered; d.error says why queue_for_a_person(ticket)Every fallback answer has fallback=True, abstain=True and confidence 0, so code that already
sends unsure answers to a person treats it the same way. A fallback must name every question
with a value that question could give (an option key, True/False, a list of option keys, a
level index, a number, a string or None); anything else is a ValueError before any request.
A mistake in the request itself (400, 401, 404, 422) is still raised, never hidden.
A question one of your rules answered keeps the rule’s answer (or stays skipped), since it needed no model: only the questions sent to the model get their fallback.
Council
Section titled “Council”d = client.decide(state, questions, council=["model-a", "model-b", "model-c"])d["team"].agreement # share of members whose top answer matches the council's2 to 5 models answer concurrently, and their probabilities are blended by geometric mean. Where members disagree, confidence drops, which is exactly what you want: disagreement is a signal to look closer. A member that fails is left out.
HTTP: "model": {"council": ["model-a", "model-b"]}.
Cascade
Section titled “Cascade”d = client.decide(state, questions, cascade=["free-model", "strong-model"], escalate_below=0.8)d["team"].answered_by # the model that gave the final answerThe cheapest model answers first. Only the questions whose confidence is below
escalate_below (default 0.8) go to the next model, and so does an answer that changed when the
options were asked in the other order (unstable); confident, steady answers stand. If the stronger
model fails, the cheaper answers are kept. When the cheap model is sure, the strong model is never
called.
HTTP: "model": {"cascade": ["free-model", "strong-model"], "escalate_below": 0.8}.
client.decide(state, questions, race=["model-a", "model-b"])All models are asked at once, the first valid answer wins, and the others are cancelled. This cuts slow outliers on shared providers, at the cost of one call per model.
HTTP: "model": {"race": ["model-a", "model-b"]}.
client.decide(state, questions, hedge=["fast-model", "backup-model"], hedge_after_ms=150)The first model is asked alone. Only if it has not answered after hedge_after_ms (default 150)
is the next one asked too; the first valid answer wins and the other is cancelled. A model that
fails outright hands over at once. You get close to a race’s protection against a slow model while
paying for the backup only when it was needed. The answer’s latency_ms includes the wait.
HTTP: "model": {"hedge": ["fast-model", "backup-model"], "after_ms": 150}.
Autopilot: Curva arranges the hedge
Section titled “Autopilot: Curva arranges the hedge”client.decide(state, questions, auto=["model-a", "model-b", "model-c"])You list the models; Curva decides the order and the wait. It keeps track of how fast each model has been answering on this server, asks the fastest first, and brings in the next one after one and a half times the leader’s usual time. A model that stops answering in time falls back by itself, and a model not measured in the last five minutes is tried first once, so a model that recovered is noticed. What it learnt is kept in memory and starts again when the server restarts.
It orders by speed only. It does not yet look at which model is right more often.
HTTP: "model": {"auto": ["model-a", "model-b", "model-c"]}.
On the command line
Section titled “On the command line”curva bench and curva map take the same plans:
curva bench --council model-a,model-bcurva map in.jsonl -q questions.json -o out.jsonl --cascade free-model,strong-model --escalate-below 0.8curva bench --race model-a,model-bUse only one of council, cascade, race, hedge or auto per request.

