mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
OmniRoute is an intelligent API gateway that unifies 20+ AI providers behind a single OpenAI-compatible endpoint. Features include intelligent routing with 6 strategies, multi-format translation (OpenAI/Claude/Gemini/Responses API), circuit breakers, semantic caching, combo fallback chains, real-time health monitoring, and a full dashboard with provider management, analytics, and CLI tool integration. Key highlights: - 20+ providers (Claude Code, Codex, Gemini CLI, GitHub Copilot, iFlow, Qwen, Kiro, etc.) - 6 routing strategies (Fill First, Round Robin, P2C, Random, Least Used, Cost Optimized) - Export/Import database backup with full archive support - Translator Playground with 4 modes (Playground, Chat Tester, Test Bench, Live Monitor) - 100% TypeScript across src/ and open-sse/ - Docker support with multi-stage builds - Comprehensive documentation and 9 dashboard screenshots
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { generateModels, generateAliasMap } from "./providerRegistry.ts";
|
|
|
|
// Provider models - Generated from providerRegistry.js (single source of truth)
|
|
export const PROVIDER_MODELS = generateModels();
|
|
|
|
// Provider ID to alias mapping - Generated from providerRegistry.js
|
|
export const PROVIDER_ID_TO_ALIAS = generateAliasMap();
|
|
|
|
// Helper functions
|
|
export function getProviderModels(aliasOrId) {
|
|
return PROVIDER_MODELS[aliasOrId] || [];
|
|
}
|
|
|
|
export function getDefaultModel(aliasOrId) {
|
|
const models = PROVIDER_MODELS[aliasOrId];
|
|
return models?.[0]?.id || null;
|
|
}
|
|
|
|
export function isValidModel(aliasOrId, modelId, passthroughProviders = new Set()) {
|
|
if (passthroughProviders.has(aliasOrId)) return true;
|
|
const models = PROVIDER_MODELS[aliasOrId];
|
|
if (!models) return false;
|
|
return models.some((m) => m.id === modelId);
|
|
}
|
|
|
|
export function findModelName(aliasOrId, modelId) {
|
|
const models = PROVIDER_MODELS[aliasOrId];
|
|
if (!models) return modelId;
|
|
const found = models.find((m) => m.id === modelId);
|
|
return found?.name || modelId;
|
|
}
|
|
|
|
export function getModelTargetFormat(aliasOrId, modelId) {
|
|
const models = PROVIDER_MODELS[aliasOrId];
|
|
if (!models) return null;
|
|
const found = models.find((m) => m.id === modelId);
|
|
return found?.targetFormat || null;
|
|
}
|
|
|
|
export function getModelsByProviderId(providerId) {
|
|
const alias = PROVIDER_ID_TO_ALIAS[providerId] || providerId;
|
|
return PROVIDER_MODELS[alias] || [];
|
|
}
|