Manages failure cooldown timers for LLM routing endpoints. Use to temporarily route traffic away from failing backends.
// Source: https://github.com/DLinacre/OmniRoute-LLM | License: MIT | Copyright 2026 diegosouzapw
// Provided via justclaw.it.com; keep this notice with the code.
interface CooldownEntry {
until: number;
reason: string;
}
const cooldowns = new Map<string, CooldownEntry>();
export interface ActiveBifrostCooldown {
remainingMs: number;
reason: string;
}
export function getBifrostFailureCooldownMs(env: NodeJS.ProcessEnv = process.env): number {
const parsed = Number.parseInt(env.OMNIROUTE_BIFROST_FAILURE_COOLDOWN_MS || "", 10);
return Number.isFinite(parsed) && parsed >= 0 ? parsed : 5000;
}
export function getActiveBifrostCooldown(
baseUrl: string,
now = Date.now()
): ActiveBifrostCooldown | null {
const entry = cooldowns.get(baseUrl);
if (!entry) return null;
if (e
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key