What Is the OmniRoute Project? A Unified AI Proxy for 290+ LLM Providers
OmniRoute is a unified AI proxy and request router that exposes a single HTTP endpoint to access approximately 290 large language model providers—including OpenAI, Anthropic, Gemini, and Groq—while centralizing streaming, authentication, combo routing, and safety guardrails.
The OmniRoute project (hosted at diegosouzapw/OmniRoute) is an open-source Next.js application that eliminates vendor lock-in by abstracting provider-specific APIs behind one OpenAI-compatible interface. It enables developers to send requests to any supported LLM through a unified gateway, apply intelligent routing strategies like cost-optimized fallbacks, and leverage a built-in ecosystem of 104 MCP tools and A2A agent capabilities.
Core Architecture of the OmniRoute Project
The OmniRoute codebase divides responsibilities into distinct layers, each handling a specific aspect of request processing, translation, or persistence.
Next.js API Layer
Incoming requests hit src/app/api/v1/chat/completions/route.ts, a Next.js API route that validates JSON payloads using Zod schemas. This layer optionally enforces API-key authentication via Authorization: Bearer headers before delegating to the internal streaming engine. It handles both streaming and non-streaming response modes uniformly.
Open-SSE Streaming Engine
The open-sse directory contains the core execution logic. The open-sse/handlers/chatCore.ts module orchestrates request processing, while open-sse/translator/index.ts transforms payloads between OpenAI, Anthropic, Gemini, and other provider formats. Provider selection occurs through open-sse/executors/index.ts, which instantiates the appropriate client implementation—most commonly open-sse/executors/default.ts for OpenAI-compatible endpoints. Rate limiting, retries, and token compression pipelines (managed by open-sse/services/compression/strategySelector.ts) execute within this layer.
MCP Server and Tool Ecosystem
OmniRoute embeds a Model Context Protocol (MCP) server defined in open-sse/mcp-server/server.ts, exposing 104 programmable tools. These include list_combos (defined in open-sse/mcp-server/tools/combo.ts), health checks, compression utilities, and third-party integrations like Notion and Obsidian. Tools communicate via SSE, HTTP, or stdio transports, allowing external agents to query configuration or trigger administrative actions.
A2A Agent Communication
The A2A server implements JSON-RPC 2.0 for agent-to-agent task management. Skills such as quotaManagement (implemented in src/lib/skills/quotaManagement.ts) expose methods like quotaManagement/check, which queries src/lib/db/quotaSnapshots.ts to return real-time usage statistics. This enables multi-agent workflows where OmniRoute acts as both LLM gateway and coordination hub.
SQLite Persistence Layer
All runtime state—including provider configurations, combo definitions, API key quotas, and request logs—persists in a local SQLite database. The connection and schema management reside in src/lib/db/core.ts, ensuring that routing decisions remain stateful across restarts without requiring external database infrastructure.
How OmniRoute Handles LLM Requests
Developers interact with OmniRoute through a single OpenAI-compatible endpoint. The following request demonstrates streaming chat completion against the unified API:
POST https://my-omniroute.example.com/api/v1/chat/completions
Content-Type: application/json
Authorization: Bearer <api-key>
{
"model": "gpt-4o",
"messages": [{ "role": "user", "content": "Explain OmniRoute in one sentence." }],
"stream": true
}
According to the OmniRoute source code, this request undergoes processing in src/app/api/v1/chat/completions/route.ts, which selects a target provider based on the model identifier and authentication context. The system then streams the response as Server-Sent Events (SSE) while optionally applying prompt-injection protection and PII redaction via src/lib/guardrails/pii-masker.ts.
Advanced Routing Strategies with Combos
OmniRoute introduces combos—ordered lists of provider targets that enable intelligent fallback and load distribution. Instead of specifying a single model, developers reference a combo ID:
{
"model": "auto-combo",
"comboId": "high-throughput",
"messages": [{ "role": "user", "content": "Summarize this article." }]
}
The combo resolution logic in open-sse/services/combo.ts parses the ResolvedComboTarget[] array, attempting each provider sequentially until one succeeds. This supports strategies like cost optimization (route to cheapest available), high availability (immediate fallback on timeout), and quality routing (prioritize specific models during peak hours).
Programmable Tool Access via MCP and A2A
Beyond LLM proxying, OmniRoute functions as a programmable tool server. The following HTTP call invokes an MCP tool to retrieve available routing configurations:
POST https://my-omniroute.example.com/api/mcp/sse
Content-Type: application/json
{
"tool": "list_combos",
"args": {}
}
The MCP server routes this to open-sse/mcp-server/tools/combo.ts, which queries the SQLite database and returns JSON definitions.
For agent-to-agent workflows, the A2A endpoint accepts JSON-RPC 2.0 payloads:
{
"jsonrpc": "2.0",
"id": 1,
"method": "quotaManagement/check",
"params": { "apiKey": "<key>" }
}
This invokes the quotaManagement skill, which reads from src/lib/db/quotaSnapshots.ts to return remaining credits and rate-limit status.
Safety and Compliance Guardrails
OmniRoute centralizes safety features in the src/lib/guardrails/ directory. The pii-masker.ts module provides optional redaction of personally identifiable information before requests reach upstream providers. Additional guardrails include prompt-injection detection and token-count enforcement, all applied within the Open-SSE pipeline before translation to provider-specific formats.
Summary
- Unified Endpoint: Access roughly 290 LLM providers through one OpenAI-compatible API managed by
src/app/api/v1/chat/completions/route.ts. - Combo Routing: Implement fallback, cost-optimization, and load-balancing strategies using the combo engine in
open-sse/services/combo.ts. - MCP Integration: Leverage 104 built-in tools via
open-sse/mcp-server/server.tsfor health checks, compression, and third-party integrations. - Agent Protocols: Coordinate multi-agent workflows using JSON-RPC 2.0 through the A2A server and skills like
quotaManagement. - Local Persistence: Store configurations and quotas in SQLite via
src/lib/db/core.tswithout external dependencies.
Frequently Asked Questions
What LLM providers does OmniRoute support?
OmniRoute supports approximately 290 providers, including OpenAI, Anthropic, Gemini, Groq, Mistral, and Fireworks. The complete registry resides in open-sse/config/providerRegistry.ts, which maps provider aliases to default URLs, authentication formats, and executor implementations.
How does OmniRoute handle authentication?
Authentication occurs at the Next.js API layer in src/app/api/v1/chat/completions/route.ts. The system validates Authorization: Bearer tokens against the SQLite database, enforcing quota checks via src/lib/db/quotaSnapshots.ts before forwarding requests to upstream providers.
What is a combo in OmniRoute?
A combo is an ordered list of provider configurations that defines a routing strategy. Defined in the database and resolved by open-sse/services/combo.ts, combos enable automatic failover, cost-optimized routing, and throughput distribution across multiple LLM backends using a single comboId parameter.
Can OmniRoute reduce token usage?
Yes. The open-sse/services/compression/strategySelector.ts module implements token compression pipelines offering lite, standard, and aggressive modes. These pipelines reduce context window usage before requests reach the provider, lowering costs while preserving semantic intent.
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 →