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
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
/**
|
|
* Moderation Provider Registry
|
|
*
|
|
* Defines providers that support the /v1/moderations endpoint.
|
|
* Follows OpenAI's moderation API format.
|
|
*/
|
|
|
|
export const MODERATION_PROVIDERS = {
|
|
openai: {
|
|
id: "openai",
|
|
baseUrl: "https://api.openai.com/v1/moderations",
|
|
authType: "apikey",
|
|
authHeader: "bearer",
|
|
models: [
|
|
{ id: "omni-moderation-latest", name: "Omni Moderation Latest" },
|
|
{ id: "text-moderation-latest", name: "Text Moderation Latest" },
|
|
],
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Get moderation provider config by ID
|
|
*/
|
|
export function getModerationProvider(providerId) {
|
|
return MODERATION_PROVIDERS[providerId] || null;
|
|
}
|
|
|
|
/**
|
|
* Parse moderation model string
|
|
*/
|
|
export function parseModerationModel(modelStr) {
|
|
if (!modelStr) return { provider: null, model: null };
|
|
|
|
for (const [providerId, config] of Object.entries(MODERATION_PROVIDERS)) {
|
|
if (modelStr.startsWith(providerId + "/")) {
|
|
return { provider: providerId, model: modelStr.slice(providerId.length + 1) };
|
|
}
|
|
}
|
|
|
|
for (const [providerId, config] of Object.entries(MODERATION_PROVIDERS)) {
|
|
if (config.models.some((m) => m.id === modelStr)) {
|
|
return { provider: providerId, model: modelStr };
|
|
}
|
|
}
|
|
|
|
return { provider: null, model: modelStr };
|
|
}
|
|
|
|
/**
|
|
* Get all moderation models as a flat list
|
|
*/
|
|
export function getAllModerationModels() {
|
|
const models = [];
|
|
for (const [providerId, config] of Object.entries(MODERATION_PROVIDERS)) {
|
|
for (const model of config.models) {
|
|
models.push({
|
|
id: `${providerId}/${model.id}`,
|
|
name: model.name,
|
|
provider: providerId,
|
|
});
|
|
}
|
|
}
|
|
return models;
|
|
}
|