OmniRoute Routing Strategies: Complete Guide to 20+ Dispatch Methods

OmniRoute supports 18 core routing strategies including priority-based, weighted, round-robin, cost-optimized, latency-aware, and ML-driven selectors, plus 6 auto-combo sub-strategies for dynamic provider selection.

The OmniRoute routing strategies determine how incoming LLM requests are distributed across providers, accounts, and models. These strategies are defined centrally in src/shared/constants/routingStrategies.ts and exposed through the strategy registry in open-sse/services/autoCombo/routerStrategy.ts. This guide covers every dispatch method available in the v3.8.51 release, with implementation details from the source code.

Core Routing Strategies

OmniRoute's primary strategies are enumerated in ROUTING_STRATEGY_VALUES (lines 2-21) and surfaced to the UI via ROUTING_STRATEGIES (lines 90-124).

Sequential and Deterministic Strategies

These strategies follow predictable patterns for provider selection:

  • priority — Executes candidates in strict order, stopping at first success. Uses icon sort.
  • round-robin — Cycles through candidates sequentially for even distribution. Uses icon autorenew.
  • fill-first — Sends requests to the first candidate with sufficient token budget. Uses icon vertical_align_top.

Probability-Based Strategies

Randomized selection methods with different sampling approaches:

  • weighted — Picks candidates according to a weight-based probability distribution. Uses icon percent.
  • random — Uniform random selection across all candidates. Uses icon shuffle.
  • strict-random — Random selection excluding recently failed candidates. Uses icon casino.
  • p2c (Power-of-Two-Choices) — Selects the better of two randomly sampled candidates. Uses icon balance.

Cost and Quota Optimized Strategies

Intelligent selection based on financial and resource constraints:

  • cost-optimized — Chooses the cheapest candidate meeting request constraints. Uses icon savings.
  • least-used — Prefers candidates with lowest recent usage count. Uses icon low_priority.
  • headroom — Selects candidates with most remaining quota headroom. Uses icon battery_charging_full.
  • reset-aware — Considers each provider's reset window during selection. Uses icon event_repeat.
  • reset-window — Strictly respects reset-window ordering to prevent quota overrun. Uses icon schedule.

Context-Aware Strategies

Selection methods optimized for request characteristics:

  • context-relay — Forwards full request context to next candidate on failure. Uses icon sync_alt.
  • context-optimized — Optimizes based on request context window size. Uses icon text_snippet.
  • cache-optimized — Prioritizes candidates with best cache-hit probability. Uses icon cached.

Advanced ML and Pipeline Strategies

Complex routing for specialized use cases:

  • lkgp (Least-Known-Good-Provider) — Uses historical performance heuristics for task-specific selection. Uses icon verified.
  • fusion — Fans requests to multiple models in parallel, merging responses via a judge model. Uses icon hub.
  • pipeline — Chains multiple models, feeding output of one as input to next. Uses icon linear_scale.

Dynamic Selection

  • auto — Dynamically selects optimal auto sub-strategy. Uses icon auto_awesome.

Auto-Combo Sub-Strategies

When auto is selected as the top-level strategy, OmniRoute resolves one of six sub-strategies registered in open-sse/services/autoCombo/routerStrategy.ts (lines 381-390). These are defined in AUTO_ROUTING_STRATEGY_VALUES (lines 38-48):

Sub-Strategy Alias Purpose
rules Classic rule-based selector with fallback to deterministic strategies
score Ranks candidates by composite score (cost, latency, headroom)
cost eco Cheapest viable candidate selection
latency fast Lowest estimated response latency
sla-aware sla Enforces SLA constraints (guaranteed latency/uptime)
lkgp Least-known-good-provider heuristic

Internal-Only Strategies

System-generated strategies never exposed in the UI are defined in INTERNAL_ROUTING_STRATEGY_VALUES (lines 31-32):

  • quota-share — Automatically created for quota-share combos

How Routing Strategies Execute

The OmniRoute routing strategy execution flow follows this path:

  1. API handlers in src/app/api/v1/.../route.ts extract strategy from request payload (defaulting to "priority")
  2. The combo dispatcher in open-sse/services/combo/* consults the strategy registry
  3. strategy.select(pool, context) is invoked (routerStrategy.ts lines 416-420)
  4. Returns ordered list of provider-account-model targets for execution

Implementation Examples

Creating a Cost-Optimized Combo

import { projectCombo } from '@/open-sse/services/combo/comboBuilder';
import { applyCombo } from '@/open-sse/services/combo/executeCombo';

const myCombo = projectCombo({
  name: 'my-cost-combo',
  strategy: 'cost-optimized',
  models: [{ provider: 'openai', model: 'gpt-4o' }],
});

const result = await applyCombo(myCombo, requestPayload);

Custom Auto Strategy with Latency Preference

import { registerStrategy } from '@/open-sse/services/autoCombo/routerStrategy';

registerStrategy('auto', {
  name: 'auto',
  description: 'Auto routing preferring latency',
  select: (pool, ctx) => {
    const latencyStrategy = getStrategy('latency');
    return latencyStrategy.select(pool, ctx);
  },
});

Key Source Files

File Role
src/shared/constants/routingStrategies.ts Central constants, normalization, UI metadata
open-sse/services/autoCombo/routerStrategy.ts Strategy name-to-implementation registry
open-sse/services/combo/* Combo execution consuming selected strategy
src/app/api/v1/*/route.ts API entry points parsing strategy field

Summary

  • 18 core strategies cover sequential, probabilistic, cost-optimized, context-aware, and advanced ML-driven routing patterns
  • 6 auto sub-strategies provide dynamic selection with aliases like eco (cost) and fast (latency)
  • 1 internal strategy (quota-share) for system-generated combos
  • All strategies route through strategy.select(pool, context) in the combo dispatcher
  • Default fallback is priority when no strategy is specified in the request payload

Frequently Asked Questions

What is the default routing strategy in OmniRoute?

OmniRoute defaults to priority routing when no strategy is explicitly specified in the request payload. This executes candidates in their configured order, stopping at the first successful response.

How does the p2c (Power-of-Two-Choices) strategy work?

The p2c strategy randomly samples two candidates from the pool and selects the better option based on internal scoring. This balances load more effectively than pure random selection while avoiding the coordination overhead of global state tracking.

Can I use multiple routing strategies together?

Yes. The fusion strategy fans requests to multiple models in parallel and merges responses, while pipeline chains models sequentially. For dynamic selection, set strategy: 'auto' and specify a sub-strategy like latency or cost to automatically adapt routing based on runtime conditions.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →