Skip to content

Enhancement: Support custom failover chains via API #122

Description

@owencari

Currently, model="auto" builds the fallback chain automatically based on the strategy's ranking (top 5 candidates). But for my use case, I want to define explicit failover chains for specific models.

Use Case

I have a production workload that should always use gpt-5.5 as primary, with claude-opus-4-7 as the first fallback, and gemini-3.1-pro-preview as the second fallback. I don't want the auto-ranking logic to reorder these — I've tested them and know this is the right order for my prompts.

Proposed API

PUT /v1/routing
{
  "strategy": "balanced",
  "custom_fallback_chains": {
    "gpt-5.5": ["claude-opus-4-7", "gemini-3.1-pro-preview"],
    "claude-opus-4-7": ["gpt-5.5", "gemini-3.1-pro-preview"]
  }
}

When a request comes in with model="gpt-5.5" (pinned, not auto), the router would use the custom chain instead of the auto-generated one.

For model="auto", the behavior could be:

  1. Auto-rank as usual to pick the primary
  2. If the primary has a custom chain defined, use that chain as the fallbacks
  3. Otherwise, use the auto-generated fallbacks

Implementation

The chat.py handler already builds fallbacks_arg from the auto candidates:

if was_auto and len(candidates) > 1:
    fallbacks_arg = [{candidates[0]: candidates[1:]}]

This could be extended to check a custom_fallback_chains dict stored on the RoutingConfig model and override the fallbacks for pinned or auto-resolved primaries.

Why Not Just Use preferred_models?

preferred_models restricts the eligible set but doesn't control the order. I want explicit control over the failover sequence, not just a filter.

Alternatives Considered

  • Using LiteLLM's fallbacks config directly — but that requires editing the code, not the API
  • Running multiple OrcaRouter instances with different configs — overkill for this use case

Would love to hear if this is in scope for Lite or if it's better suited for the Teams edition.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions