mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 15:22:12 +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
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { create } from "zustand";
|
|
|
|
const useProviderStore = create((set, get) => ({
|
|
providers: [],
|
|
loading: false,
|
|
error: null,
|
|
|
|
setProviders: (providers) => set({ providers }),
|
|
|
|
addProvider: (provider) => set((state) => ({ providers: [provider, ...state.providers] })),
|
|
|
|
updateProvider: (id, updates) =>
|
|
set((state) => ({
|
|
providers: state.providers.map((p) => (p._id === id ? { ...p, ...updates } : p)),
|
|
})),
|
|
|
|
removeProvider: (id) =>
|
|
set((state) => ({
|
|
providers: state.providers.filter((p) => p._id !== id),
|
|
})),
|
|
|
|
setLoading: (loading) => set({ loading }),
|
|
|
|
setError: (error) => set({ error }),
|
|
|
|
fetchProviders: async () => {
|
|
set({ loading: true, error: null });
|
|
try {
|
|
const response = await fetch("/api/providers");
|
|
const data = await response.json();
|
|
if (response.ok) {
|
|
set({ providers: data.providers, loading: false });
|
|
} else {
|
|
set({ error: data.error, loading: false });
|
|
}
|
|
} catch (error) {
|
|
set({ error: "Failed to fetch providers", loading: false });
|
|
}
|
|
},
|
|
}));
|
|
|
|
export default useProviderStore;
|