OmniRoute Routing Strategies: The Complete Guide to All 19 Dispatch Methods

OmniRoute provides 19 distinct routing strategies defined in src/shared/constants/routingStrategies.ts that control how requests are dispatched across AI providers, ranging from simple round-robin to advanced Power-of-Two-Choices load balancing.

The open-source OmniRoute project (diegosouzapw/OmniRoute) uses a combo engine to intelligently route requests between multiple AI models and providers. These routing strategies determine target selection logic, with each strategy optimized for specific latency, cost, reliability, or throughput requirements.

How Routing Strategies Work in OmniRoute

All available strategies are exported as the ROUTING_STRATEGY_VALUES constant from src/shared/constants/routingStrategies.ts. This array powers the combo configuration UI in src/app/(dashboard)/dashboard/combos/page.tsx and the runtime engine in open-sse/services/combo/comboSetup.ts.

When you create a combo using createCombo() in src/lib/db/combo.ts, you assign a strategy that the routing engine uses to select targets for each request.

The Complete List of OmniRoute Routing Strategies

The strategies fall into five functional categories based on their optimization goals.

Basic Selection Strategies

These strategies provide straightforward target selection without complex state tracking:

  • priority – Always selects the first target in the list, creating a primary/fallback hierarchy.
  • weighted – Distributes traffic according to assigned numerical weights, allowing proportional load allocation.
  • round-robin – Cycles through targets sequentially in a fixed order, ensuring equal distribution over time.
  • random – Selects targets using uniform random distribution for basic load spreading.
  • strict-random – Random selection with enhanced fairness guarantees to prevent statistical clustering.

Load Balancing and Quota Management

These strategies monitor provider capacity and usage metrics to prevent overload:

  • p2c (Power-of-Two-Choices) – Randomly samples two targets and selects the one with lower load, reducing tail latency without maintaining global state.
  • fill-first – Saturates the first target until it hits a configured limit, then spills overflow to subsequent targets.
  • least-used – Routes to the target with the lowest recent utilization count.
  • headroom – Selects the provider with the most remaining quota headroom relative to its limits.
  • reset-aware – Prefers providers that have recently reset their usage counters, avoiding quota-exhausted targets.
  • reset-window – Applies a sliding-window policy for quota management, gradually shifting traffic as windows advance.

Cost and Performance Optimization

Strategies that optimize for economic or runtime efficiency:

  • cost-optimized – Dynamically selects the cheapest available provider that satisfies request requirements.
  • auto – The built-in Auto Combo strategy that analyzes real-time metrics to dynamically choose the best target.
  • context-optimized – Prioritizes providers that handle the current context window size efficiently, avoiding token limit penalties.
  • cache-optimized – Prefers providers where results benefit from caching layers, reducing redundant computation.

Context-Aware and Fallback Routing

Strategies that preserve request state or learn from execution history:

  • context-relay – Forwards requests to the next target while preserving conversation context, enabling transparent failover.
  • lkgp (Last-Known-Good-Provider) – Records which provider succeeded for specific request types and prefers that provider for similar subsequent requests.

Composite Processing Strategies

Advanced strategies that modify request flow through multi-provider pipelines:

  • fusion – Parallelizes requests across multiple providers and combines their results into a single unified response.
  • pipeline – Chains providers sequentially, piping the output of one model as input to the next for multi-stage processing.

Internal Strategy

While the UI and API expose 19 strategies, OmniRoute includes one internal-only method:

  • quota-share – Used by automatically generated combos for distributed quota management across provider accounts; it is intentionally excluded from public API endpoints and the dashboard configuration.

Implementing Routing Strategies in Code

To inspect available strategies programmatically, import the canonical constant:

import { ROUTING_STRATEGY_VALUES } from '@/shared/constants/routingStrategies';

// Display all 19 user-facing strategies
console.log('Available routing strategies:', ROUTING_STRATEGY_VALUES);

When persisting a combo configuration via the database layer, pass the strategy identifier:

import { createCombo } from '@/lib/db/combo';
import { ROUTING_STRATEGY_VALUES } from '@/shared/constants/routingStrategies';

async function setupWeightedCombo() {
  const combo = await createCombo({
    name: 'production-llm',
    strategy: 'weighted',
    targets: [
      { provider: 'openai', model: 'gpt-4', weight: 70 },
      { provider: 'anthropic', model: 'claude-3', weight: 30 },
    ],
  });
  console.log('Created combo with strategy:', combo.strategy);
}

For normalizing user input against the canonical list, use the helper function:

import { normalizeRoutingStrategy } from '@/shared/constants/routingStrategies';

const userInput = 'Cost';
const normalized = normalizeRoutingStrategy(userInput);
// Returns: "cost-optimized"

Summary

  • OmniRoute defines 19 user-facing routing strategies in src/shared/constants/routingStrategies.ts, exported as the ROUTING_STRATEGY_VALUES array.
  • Strategies range from simple priority and round-robin to advanced algorithms like p2c (Power-of-Two-Choices) and context-relay.
  • Cost-optimized and auto strategies enable dynamic provider selection based on price or real-time performance metrics.
  • Fusion and pipeline support complex multi-provider workflows, while lkgp provides intelligent retry capabilities based on historical success.
  • An internal quota-share strategy handles automatic quota distribution but remains hidden from the public API and combo configuration UI.

Frequently Asked Questions

What is the difference between random and strict-random in OmniRoute?

Both strategies select targets probabilistically, but strict-random enforces stricter fairness guarantees to prevent statistical clustering over short time windows. Standard random uses uniform distribution that may temporarily favor certain targets during small sample sizes.

When should I use the p2c routing strategy?

Use p2c (Power-of-Two-Choices) when you need distributed load balancing without maintaining global state. By sampling two random targets and picking the less loaded one, it significantly reduces tail latency compared to pure random selection while avoiding the complexity of centralized coordination.

How does the auto strategy differ from cost-optimized?

The auto strategy evaluates multiple runtime metrics including latency, error rates, and throughput to select the best target dynamically, while cost-optimized focuses exclusively on minimizing monetary cost per request. Use auto for performance-critical applications and cost-optimized for budget-sensitive batch processing.

Why is quota-share not available in the routing strategies UI?

The quota-share strategy is reserved for internal use by OmniRoute's automatically generated combos that manage distributed quota allocation across provider accounts. It is intentionally excluded from ROUTING_STRATEGY_VALUES and the dashboard UI in src/app/(dashboard)/dashboard/combos/page.tsx to prevent manual misconfiguration of quota-sharing logic.

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 →