#15216·onyx

Feature request: Native LLM routing, failover, load balancing, and smart model selection

Author: TomakataABCCreated Sep 29, 2026Updated Sep 29, 2026

Feature request

Onyx currently supports configuring multiple LLM providers/models, but routing between them is largely explicit: a model/provider is selected and requests are sent there.

For deployments using multiple providers or models, this often means running an additional gateway such as LiteLLM or Portkey purely to provide routing, failover, or load balancing.

This adds another service to operate, configure, secure, monitor, and keep compatible with Onyx.

It would be useful if Onyx had a native routing layer between its application logic and configured LLM providers.

What I would like to see

Allow administrators to define a logical model/router backed by multiple models and providers.

The user or Agent would select something like General Assistant, while the router decides which actual model/provider should receive each request.

The router could support several strategies:

  • Failover: try an ordered list of backends when a provider is unavailable, rate limited, times out, or returns selected errors.
  • Load balancing: distribute requests using round robin, weighted routing, latency, rate limits, cost, or similar criteria.
  • Smart routing: choose a model based on request characteristics such as task type, complexity, required capabilities, context length, tool usage, vision requirements, latency, cost, or administrator-defined rules.

Smart routing could start as rule-based configuration and optionally support a classifier/LLM-based router later.

Why implement this in Onyx?

Today, this kind of setup can be achieved by putting an external gateway in front of Onyx, for example:

Onyx
  -> LiteLLM / Portkey / another gateway
      -> Anthropic
      -> OpenAI
      -> local models
      -> other providers

Those projects are useful, but for relatively common routing requirements it feels unnecessary to run an additional infrastructure component solely for this purpose.

Onyx already knows quite a lot about the request:

  • selected Agent
  • tools available
  • whether search is involved
  • attachments
  • conversation state
  • model capability requirements
  • user/admin configuration

That makes Onyx itself potentially a good place to make routing decisions.

It could also avoid situations where routing is split between Onyx and an external gateway, with each having only partial context about why a particular LLM call is being made.

Internal/background LLM calls

The same routing abstraction could also be useful for internal operations.

Classification, query expansion, naming, and other lightweight tasks may not need the same model used for the final user-facing response. Routing could therefore take both the request and the specific Onyx workload into account.

Possible first implementation

I don't think the first version needs a sophisticated AI router.

An incremental implementation could be:

  1. Introduce a "router" or "logical model" abstraction.
  2. Allow multiple provider/model targets.
  3. Add priority-based fallback.
  4. Add weighted or round-robin routing.
  5. Later expose request metadata for rule-based or classifier-based routing.

Even the first few steps could remove the need for an external LLM gateway in many deployments while leaving room for more advanced routing later.

Would the maintainers be interested in a design along these lines?