Skip to content

Feature: Add per-provider weight/priority configuration for routing decisions #114

Description

@leomete

Context

Currently, model="auto" selects models based on strategy (cheapest/balanced/fastest/quality) without any way for the operator to express provider preference. In my homelab setup, I have keys for OpenAI, Anthropic, and Groq, but I'd prefer to route to Groq first (cheapest + fastest for my workload) and only fall back to OpenAI/Anthropic when Groq is rate-limited or down.

Problem

The choose_auto_model function in app/auto_routing.py ranks models purely by the strategy's scoring logic. There's no way to say "prefer provider X" or "avoid provider Y unless necessary". The preferred_models list is model-level, not provider-level, and requires me to maintain a hardcoded list of model IDs that drifts as the catalog updates.

Proposed API

Add a provider_weights field to the routing config:

PUT /v1/routing
{
  "strategy": "balanced",
  "provider_weights": {
    "groq": 2.0,
    "openai": 1.0,
    "anthropic": 0.5
  }
}

The weight would multiply the normalized score (or add a bonus to the cost) so that a provider with weight 2.0 is preferred over one with weight 1.0, all else being equal. Weight 0 would exclude the provider entirely.

Implementation Sketch

In auto_routing.py, after computing the per-model score, apply the provider weight:

def _weighted_score(model_score: float, provider: str, weights: dict[str, float]) -> float:
    w = weights.get(provider, 1.0)
    if w <= 0:
        return float('-inf')  # exclude
    return model_score * w

This would slot into the existing sort key without major refactoring.

Why This Matters

Self-hosters often have cost/latency preferences that don't align with pure strategy optimization. Provider-level weighting gives fine-grained control without abandoning the model="auto" convenience.

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