The 19 Routing Strategies Available in OmniRoute: Complete Guide

OmniRoute provides 19 distinct routing strategies ranging from simple priority-based selection to advanced fusion and pipeline processing, all defined in src/shared/constants/routingStrategies.ts and exposed via the ROUTING_STRATEGY_VALUES constant.

OmniRoute's combo engine intelligently dispatches requests across AI providers using sophisticated routing logic. Understanding the routing strategies available in OmniRoute is essential for optimizing cost, latency, and reliability in production deployments. This guide examines all 19 strategies implemented in the diegosouzapw/OmniRoute repository, explaining when to use each algorithm based on the source code in src/shared/constants/routingStrategies.ts.

Where OmniRoute Defines Its Routing Strategies

The canonical list of routing strategies resides in src/shared/constants/routingStrategies.ts. This file exports the ROUTING_STRATEGY_VALUES constant, which enumerates all user-facing options, along with helper utilities like normalizeRoutingStrategy(). The combo configuration UI at src/app/(dashboard)/dashboard/combos/page.tsx, the API layer, and the internal routing engine all import these definitions to maintain consistency across the stack.

The 19 Routing Strategies Available in OmniRoute

OmniRoute categorizes its routing algorithms into distribution methods, load-balancing techniques, cost optimizers, and advanced processing modes.

Basic Distribution Strategies

These methods handle straightforward target selection without complex state tracking.

priority – Always selects the first target in the configuration list. Use this when you have a primary provider that should handle all traffic unless it fails.

weighted – Distributes traffic according to assigned percentage weights. Ideal for gradual migrations or maintaining specific capacity ratios between providers.

round-robin – Cycles through targets in a fixed sequential order. Best for evenly distributing load across equally-capable providers without preference.

random – Selects targets uniformly at random. Suitable for basic load spreading when you don't need sophisticated distribution guarantees.

strict-random – Random selection with stricter fairness guarantees than standard random. Use when you need statistical uniformity over shorter time windows.

Load-Aware and Quota-Based Strategies

These algorithms consider current system state, usage history, and remaining capacity.

p2c (Power-of-Two-Choices) – Randomly samples two targets and selects the one with lower load. This provides better load distribution than pure randomness with minimal overhead.

least-used – Prefers the target that has been used least recently. Effective for maintaining even wear across providers or avoiding hotspotting.

headroom – Selects the target with the most remaining quota headroom. Critical for high-volume applications approaching rate limits.

fill-first – Completely saturates the first target before moving to the next. Useful when you want to maximize free tier usage or exhaust cheaper providers first.

reset-aware – Prefers targets that recently reset their usage counters. Optimizes for providers with rolling window rate limits.

reset-window – Uses a sliding-window reset policy for quota management. Best for providers with complex reset schedules.

Cost and Context Optimization

These strategies optimize for economic efficiency and request compatibility.

cost-optimized – Selects the cheapest target that satisfies the request requirements. Essential for budget-conscious applications with provider cost variance.

context-optimized – Prioritizes providers that can handle the current context size efficiently. Prevents token limit errors by matching content length to provider capabilities.

cache-optimized – Prefers providers that benefit from cached results. Maximizes cache hit rates when using OmniRoute's response caching layer.

lkgp (Last-Known-Good-Provider) – Falls back to the last provider that succeeded for the same request type. Provides resilience by learning from successful patterns.

Advanced Processing Strategies

These enable complex request handling beyond simple routing.

context-relay – Relays the request to the next target while preserving conversation context. Enables seamless provider switching mid-conversation.

fusion – Combines results from multiple providers into a single response. Use when you want to aggregate outputs or ensemble model predictions.

pipeline – Pipes the output of one provider as input to the next, forming a processing chain. Ideal for multi-stage workflows like summarization followed by translation.

auto – The built-in Auto Combo strategy that dynamically selects the best target based on real-time metrics including latency, cost, and success rates. Recommended for most production workloads that don't require specific routing logic.

Internal Strategy

quota-share – An internal-only strategy used by automatically generated combos for quota sharing. This strategy is not exposed in the UI or public API and is reserved for system-managed configurations.

Implementing Routing Strategies in Code

To utilize these strategies in your OmniRoute deployment, import the constants and helpers from the routing strategies module.

Listing All Available Strategies

Retrieve the complete strategy catalog programmatically:

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

// Print the full list
console.log('Available routing strategies:', ROUTING_STRATEGY_VALUES);

Creating a Combo with a Specific Strategy

When configuring a combo via the database layer in src/lib/db/combo.ts, specify the strategy property using any value from ROUTING_STRATEGY_VALUES:

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

async function makeCombo() {
  const combo = await createCombo({
    name: 'my-combo',
    strategy: 'weighted',                // any value from ROUTING_STRATEGY_VALUES
    targets: [{ provider: 'openai', model: 'gpt-4' }],
  });
  console.log('Combo created with strategy:', combo.strategy);
}

Normalizing User Input

The normalizeRoutingStrategy() helper resolves variant inputs to canonical strategy names:

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

const userInput = 'Cost';
const strategy = normalizeRoutingStrategy(userInput);
console.log('Normalized strategy:', strategy); // → "cost-optimized"

Summary

  • OmniRoute defines 19 user-facing routing strategies in src/shared/constants/routingStrategies.ts, plus one internal quota-share strategy.
  • Distribution strategies (priority, weighted, round-robin, random, strict-random) handle basic traffic allocation.
  • Load-aware strategies (p2c, least-used, headroom, fill-first, reset-aware, reset-window) optimize for capacity and rate limits.
  • Cost and context strategies (cost-optimized, context-optimized, cache-optimized, lkgp) maximize efficiency and compatibility.
  • Advanced strategies (context-relay, fusion, pipeline, auto) enable complex processing workflows and dynamic optimization.
  • Use the ROUTING_STRATEGY_VALUES constant and normalizeRoutingStrategy() helper to interact with the strategy system programmatically.

Frequently Asked Questions

What is the default routing strategy in OmniRoute?

The auto strategy serves as the default recommendation for most use cases, dynamically selecting targets based on runtime metrics including latency, cost, and success rates. However, the specific default depends on your combo configuration in src/lib/db/combo.ts.

How do I implement custom routing logic beyond the 19 built-in strategies?

OmniRoute does not support custom strategy plugins directly. You should extend the combo engine by configuring multiple combos with different strategies and orchestrating them at the application layer, or modify the source in src/shared/constants/routingStrategies.ts and rebuild the application.

Which routing strategy minimizes API costs?

The cost-optimized strategy explicitly selects the cheapest provider that satisfies request requirements. For maximum savings, combine this with fill-first to exhaust free tiers before consuming paid quotas.

Can I use multiple routing strategies simultaneously?

While you assign only one strategy per combo definition, you can create hierarchical routing by using the fusion or pipeline strategies to process requests across multiple providers, or by creating separate combos with different strategies and routing between them at the application level.

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 →