The 19 Routing Strategies Available in OmniRoute: Complete Technical Reference

OmniRoute provides 19 distinct routing strategies defined in src/shared/constants/routingStrategies.ts that control how the combo engine dispatches requests across AI providers, ranging from simple priority-based selection to advanced pipeline and fusion modes.

OmniRoute (diegosouzapw/OmniRoute) is an open-source routing layer designed to intelligently distribute AI requests across multiple providers and models. The routing strategies available in OmniRoute serve as the decision-making logic for the combo engine, determining exactly which target handles each incoming request based on configurable heuristics. These strategies are exposed through the ROUTING_STRATEGY_VALUES constant and utilized by both the dashboard UI and the core routing engine.

Where Routing Strategies Are Defined

The canonical definition of all routing strategies resides in src/shared/constants/routingStrategies.ts. This file exports the ROUTING_STRATEGY_VALUES constant, which enumerates the 19 user-facing strategies that can be assigned to any combo configuration.

In addition to the public strategies, the same file defines an internal-only strategy called quota-share. This strategy is reserved for automatically generated combos that handle quota sharing between providers and is not exposed in the UI or public API.

The 19 Routing Strategies Explained

OmniRoute's combo engine supports the following routing strategies, each optimized for specific operational requirements:

Load Distribution Strategies

  • priority: Always selects the first (highest-priority) target in the list.
  • weighted: Distributes requests across targets based on assigned numeric weights.
  • round-robin: Cycles through targets in a fixed sequential order.
  • random: Selects a target uniformly at random.
  • strict-random: Random selection with stricter fairness guarantees to prevent clustering.
  • p2c (Power-of-Two-Choices): Randomly samples two targets and selects the one with lower load, offering better load balancing than pure random selection.

Resource Optimization Strategies

  • least-used: Prefers the target that has been used least recently.
  • cost-optimized: Selects the cheapest target that satisfies the request requirements.
  • headroom: Chooses the target with the most remaining quota headroom to prevent saturation.
  • reset-aware: Prefers targets that have recently reset their usage counters.
  • reset-window: Uses a sliding-window reset policy for sophisticated quota management.

Context and State Management Strategies

  • context-relay: Relays the request to the next target while preserving the full conversation context.
  • context-optimized: Prioritizes providers that can handle the current context size efficiently.
  • lkgp (Last-Known-Good-Provider): Falls back to the last provider that succeeded for the same request type, optimizing for reliability.
  • cache-optimized: Prefers providers that benefit from cached results to reduce latency and cost.

Advanced Processing Strategies

  • fill-first: Fills the first target until it reaches a configured limit, then moves to the next target.
  • auto: The built-in Auto Combo strategy that dynamically selects the best target based on real-time runtime metrics.
  • fusion: Combines results from multiple providers into a single unified response.
  • pipeline: Pipes the output of one provider as input to the next, forming a sequential processing pipeline.

Implementing Routing Strategies in Code

The ROUTING_STRATEGY_VALUES constant provides type-safe access to all available strategies. Below are practical implementations for common use cases.

Listing All Available Strategies

To retrieve the complete list of supported strategies for validation or UI display:

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

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

Creating a Combo with a Specific Strategy

When persisting a combo configuration to the database using the createCombo function from src/lib/db/combo.ts:

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 Strategy Input at Runtime

The normalizeRoutingStrategy helper ensures user input matches the canonical strategy names:

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

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

Architecture and Key Files

The routing strategies are integrated across multiple layers of the OmniRoute architecture:

  • src/shared/constants/routingStrategies.ts: Contains the canonical ROUTING_STRATEGY_VALUES array, strategy type definitions, and the normalizeRoutingStrategy utility.

  • src/app/(dashboard)/dashboard/combos/page.tsx: The React dashboard component that renders the strategy selection UI, importing values from the constants file to populate dropdown menus.

  • open-sse/services/combo/comboSetup.ts: The combo engine service that imports the strategy list to configure runtime request routing behavior.

  • src/lib/db/combo.ts: The database abstraction layer that persists combo configurations, enforcing that the strategy field contains only valid values from ROUTING_STRATEGY_VALUES.

Summary

  • OmniRoute defines 19 user-facing routing strategies in src/shared/constants/routingStrategies.ts, exposed through the ROUTING_STRATEGY_VALUES constant.
  • Strategies range from simple selection methods (priority, round-robin) to sophisticated multi-provider patterns (fusion, pipeline, p2c).
  • An internal quota-share strategy exists for automatic quota management but remains unexposed in the public API.
  • The normalizeRoutingStrategy helper ensures runtime input validation against the canonical strategy list.
  • Strategy selection directly impacts cost, latency, and reliability characteristics of AI request routing.

Frequently Asked Questions

How do I programmatically validate a routing strategy string against OmniRoute's supported values?

Import the normalizeRoutingStrategy function from src/shared/constants/routingStrategies.ts. This utility accepts user input strings and returns the normalized canonical name or throws an error for invalid strategies, ensuring type safety before database persistence or runtime configuration.

What is the difference between the random and strict-random routing strategies?

While both select targets probabilistically, random performs uniform random selection without guarantees, whereas strict-random implements stricter fairness guarantees to prevent request clustering on specific targets over time, providing more equitable load distribution across high-volume workloads.

Can I use the quota-share strategy in my custom combo configurations?

No. The quota-share strategy is reserved for internal use by automatically generated combos that manage provider quota sharing. It is intentionally excluded from ROUTING_STRATEGY_VALUES and inaccessible through both the dashboard UI (src/app/(dashboard)/dashboard/combos/page.tsx) and the public API.

Which routing strategy should I choose for minimizing API costs?

The cost-optimized strategy explicitly selects the cheapest provider that satisfies your request requirements. For additional savings, consider cache-optimized, which prioritizes providers with cached responses, or lkgp (Last-Known-Good-Provider), which avoids costly retries by sticking with proven reliable providers.

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 →