19 Routing Strategies in OmniRoute: Complete Reference Guide
OmniRoute provides 19 distinct routing strategies for LLM request dispatch, defined in src/shared/constants/routingStrategies.ts as the ROUTING_STRATEGY_VALUES constant.
These strategies power the OmniRoute combo engine, determining how each request is routed across multiple providers and models. Whether you need cost optimization, load balancing, or intelligent context handling, OmniRoute's routing system offers granular control over provider selection. This guide covers all 19 strategies with implementation details from the source code.
Priority-Based Routing Strategies
priority
The priority strategy always selects the first (highest-priority) target in the combo list. This is the simplest routing approach—ideal when you have a clear preferred provider and want automatic fallback only when that primary fails.
weighted
The weighted strategy distributes requests according to assigned weight values. Configure higher weights for preferred providers to shift traffic proportionally while maintaining backup options.
round-robin
The round-robin strategy cycles through targets in a fixed, repeating order. This ensures equal distribution across all configured providers regardless of their performance characteristics.
Load-Aware and Performance Strategies
p2c (Power-of-Two-Choices)
The p2c strategy implements the classic power-of-two-choices algorithm: randomly sample two targets and pick whichever has lower current load. This provides near-optimal load balancing with minimal overhead compared to perfect global state tracking.
least-used
The least-used strategy routes to the target with the lowest recent usage count. Unlike round-robin, this adapts to actual traffic patterns and can handle targets with different capacity profiles.
headroom
The headroom strategy selects the target with the most remaining quota headroom. Critical for multi-tenant deployments where soft limits must be respected to avoid hard quota violations.
reset-aware
The reset-aware strategy prefers targets that have recently reset their usage counters. Useful when provider quotas reset on calendar boundaries (monthly, daily) and you want to consume fresh quotas aggressively.
reset-window
The reset-window strategy applies a sliding-window reset policy for quota management. Smoother than strict reset-aware routing, this prevents thundering-herd problems when multiple quotas reset simultaneously.
Cost and Optimization Strategies
cost-optimized
The cost-optimized strategy selects the cheapest target that satisfies request requirements. The engine evaluates per-token pricing across configured providers and chooses the minimum-cost option meeting quality thresholds.
context-optimized
The context-optimized strategy prioritizes providers that handle the current context size efficiently. Some providers price context windows non-linearly—this strategy accounts for total input length, not just per-token rates.
cache-optimized
The cache-optimized strategy prefers providers where cached results are more likely to hit. OmniRoute tracks embedding and completion cacheability to minimize redundant compute.
Advanced Routing Patterns
context-relay
The context-relay strategy forwards requests to the next target while preserving full conversation context. Essential for multi-turn conversations where provider switching must maintain state continuity.
fill-first
The fill-first strategy exhausts the first target's capacity before migrating traffic to the next. Useful for burning through committed spend or free-tier allowances before consuming paid capacity elsewhere.
random
The random strategy selects targets uniformly at random. Simple and stateless, though without fairness guarantees under skewed load.
strict-random
The strict-random strategy provides random selection with enforced fairness guarantees. Uses reservoir sampling or similar techniques to ensure statistical evenly distribution over time windows.
Intelligent and Composite Strategies
auto
The auto strategy enables Auto Combo mode, where OmniRoute dynamically selects optimal targets based on real-time metrics: latency, error rates, cost curves, and quota status. The built-in adaptive engine continuously re-evaluates provider scores.
lkgp (Last-Known-Good-Provider)
The lkgp strategy implements resilient fallback by tracking which provider last succeeded for each request type. Routes new similar requests to proven reliable paths first.
fusion
The fusion strategy combines results from multiple providers into a single unified response. The engine dispatches in parallel and merges outputs—useful for ensemble approaches or confidence scoring.
pipeline
The pipeline strategy chains providers sequentially, piping one provider's output as the next's input. Enables multi-stage processing: initial generation, refinement, format conversion, or safety filtering across specialized models.
Quota Management Strategy (Internal)
quota-share
The quota-share strategy is internal-only, used by automatically generated combos for quota sharing across provider accounts. This strategy is not exposed in the UI or public API and is reserved for system-managed routing configurations.
Working with Routing Strategies in Code
Listing Available Strategies
Access the complete strategy catalog through ROUTING_STRATEGY_VALUES:
import { ROUTING_STRATEGY_VALUES } from '@/shared/constants/routingStrategies';
// Print all 19 user-facing strategies
console.log('Available routing strategies:', ROUTING_STRATEGY_VALUES);
// Output: ['priority', 'weighted', 'round-robin', 'context-relay', ...]
Creating a Combo with Specific Strategy
import { createCombo } from '@/lib/db/combo';
import { ROUTING_STRATEGY_VALUES } from '@/shared/constants/routingStrategies';
async function makeCostOptimizedCombo() {
const combo = await createCombo({
name: 'budget-combo',
strategy: 'cost-optimized',
targets: [
{ provider: 'openrouter', model: 'claude-3-haiku' },
{ provider: 'together', model: 'llama-3-8b' },
],
});
return combo;
}
Normalizing User Input
The normalizeRoutingStrategy helper handles case-insensitive matching and aliases:
import { normalizeRoutingStrategy } from '@/shared/constants/routingStrategies';
const userInput = 'RoundRobin'; // messy user input
const strategy = normalizeRoutingStrategy(userInput);
console.log(strategy); // → "round-robin"
Source Code Reference
| File | Purpose |
|---|---|
src/shared/constants/routingStrategies.ts |
Canonical strategy definitions and ROUTING_STRATEGY_VALUES export |
src/app/(dashboard)/dashboard/combos/page.tsx |
Dashboard UI for strategy selection |
open-sse/services/combo/comboSetup.ts |
Runtime strategy resolution for the combo engine |
src/lib/db/combo.ts |
Database persistence of combo configurations |
Summary
- 19 total strategies including 18 user-facing options plus internal
quota-share - 4 categories: priority-based, load-aware, cost-optimized, and intelligent composite strategies
- Source of truth:
ROUTING_STRATEGY_VALUESinsrc/shared/constants/routingStrategies.ts - Key capabilities: Auto Combo (
auto), resilient fallback (lkgp), parallel fusion (fusion), sequential pipelines (pipeline) - Normalization helper:
normalizeRoutingStrategy()for robust input handling
Frequently Asked Questions
What is the default routing strategy in OmniRoute?
OmniRoute does not enforce a universal default—each combo specifies its own strategy. However, the priority strategy is simplest and commonly used for primary/backup configurations. The auto strategy is recommended for production when you want adaptive optimization without manual tuning.
How does the p2c strategy differ from random selection?
p2c (Power-of-Two-Choices) samples exactly two random targets and selects the less-loaded one, achieving O(log log n) maximum load with minimal coordination overhead. Pure random selection can create hotspots since it ignores current system state entirely.
Can I combine multiple routing strategies in one combo?
Individual combos use exactly one strategy, but fusion and pipeline strategies compose provider interactions internally. For true multi-strategy behavior, create nested combos where an outer combo routes between inner combos using different strategies.
Why is quota-share not available in the UI?
The quota-share strategy is reserved for system-generated combos that manage quota allocation across provider accounts automatically. Exposing it would allow configuration conflicts with OmniRoute's internal resource accounting. Use weighted, headroom, or reset-aware for manual quota-aware routing instead.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →