Skip to content
All projects
AI Infrastructure2026

MoonRouter — Smart Multi-API LLM Proxy & Model Rotation System

A self-healing, multi-provider LLM gateway that hides 4 free AI providers behind one OpenAI-compatible endpoint — with automatic failover, API-key rotation, health-aware cooldowns and zero-downtime model swaps.

MoonRouter — Smart Multi-API LLM Proxy & Model Rotation System preview

Project Overview

MoonRouter is a production-grade smart LLM proxy built on LiteLLM that turns a zoo of AI providers into one stable, OpenAI-compatible endpoint. Coding agents like OpenCode (and any OpenAI SDK client) see just three logical models — coding, reasoning, backup — while the router decides, per request, which real provider serves them: Cerebras, Groq (dual-key rotation), Google Gemini or OpenRouter free-tier models.

The system is engineered for resilience: a failed deployment is retried once, then skipped; two consecutive failures put a provider into a 5-minute cooldown so rate-limited or dead endpoints are never hammered. Context-window pre-call checks reroute oversized prompts to bigger-context models, per-deployment max_output_tokens clamp runaway client requests, and RPM caps protect free-tier quotas. Failover chains (coding → reasoning → backup) guarantee an answer as long as any provider is alive.

Operations are deliberately boring: a single declarative YAML file defines every deployment, key and failover rule; Docker Compose runs the router as a healthy-checked container bound to 127.0.0.1 with the master key and secrets injected via environment; a documented 10-step runbook covers port, health, models, keys and routing diagnostics. When a provider deprecates a model, one config edit and a container restart swaps it — clients never notice.

Key Contributions

Unified 4 AI providers (Cerebras, Groq, Gemini, OpenRouter) behind one OpenAI-compatible endpoint on 127.0.0.1:4000
Designed logical model groups (coding / reasoning / backup) with automatic cross-group failover chains
Implemented self-healing provider health: 1 fast retry, 2-strike rule, 5-minute cooldowns and live /health reporting
Rotates two Groq API keys as sibling deployments and rate-limits free-tier OpenRouter models with RPM caps
Enforced context-window pre-call checks and per-deployment output-token clamps for oversized client requests
Shipped as a hardened Docker Compose stack: master-key auth, gitignored secrets, read-only config mount and container healthchecks

Features

One stable OpenAI-compatible /v1 endpoint for every LLM client
Automatic failover: coding → reasoning → backup chains
API-key rotation across multiple deployments of the same model
5-minute cooldowns for failing or rate-limited providers
Provider health report (/health) with per-deployment UP/DOWN status
Zero-downtime provider swaps — YAML-only config changes
Let's work together

Have an idea? Let's build something extraordinary.

From full stack products to DevOps automation and AI-powered features — I'm available for freelance projects and full-time roles. Let's turn your vision into production software.