whereismyai
Shanhai Gateway
Shanhai Gateway is an open-source API gateway that organizes multiple upstream AI models into a single OpenAI-compatible endpoint with weighted round-robin routing.
Shanhai Gateway is an API gateway designed to organize multiple upstream AI model providers into a single OpenAI-compatible endpoint. It helps users manage and stabilize AI workloads by routing requests through a combination of commercial channels, subscription pools, and free tiers. The software features weighted round-robin rotation, task-level session affinity for prefix caching, and error-classification-driven cooldowns to prevent failures. It includes automated quota probes and a sidecar process that removes exhausted backends automatically. The project is built for developers and operators managing heavy production workloads who need reliable cost reduction and fault tolerance.
Shanhai Gateway at a glance
- Best for: Software engineer
- Runs on: Docker, Linux, API, open source
- Pricing: Free and open source
- Released: November 2026
- Category: AI coding tool
- Website: github.com/ffseika0304/shanhai-gateway
Key features
- Weighted round-robin load balancing and fallback isolation
- Error-classification-driven exponential cooldowns
- Task-level session affinity for prefix cache reuse
- Multi-user downstream API key billing
- SQLite-based shadow retention observation and stats board
- Hot-reloading configuration support
- Sidecar process for slow-cycle self-healing and quota management
Use it for
- Combining free and paid upstream AI models into one stable endpoint
- Lowering operational token costs through intelligent request routing
- Maintaining high availability during upstream model outages
- Managing multi-user API key quotas and billing
Alternatives to Shanhai Gateway
- OrcaRouter — Route requests to the best models without paying token markups.
- OpenRouter — Access over 500 models and 80 providers through one unified API.
- OmniRoute — Routes requests across 352 providers with automatic fallback and cost-based selection.
- New API — Unifies access to 30 plus AI providers with intelligent routing and cost control.
- Kong AI Gateway — Manages, secures, and governs API and LLM traffic across platforms.
- LiteLLM — One OpenAI-format API for 100+ LLM providers
- GoRoute — Consumes 5.1MB of RAM with sub-10ms latency for coding agents.
- FreeLLMAPI — Accesses hundreds of free LLM models and billions of tokens through one API key.
- agentgateway — It unifies service, LLM, and MCP traffic into one open-source binary.
- Eden AI — Integrate hundreds of AI models through one unified API with smart routing.
- Bifrost — High-performance gateway with 20 microsecond overhead and 5000 requests per second throughput.
- FastAIToken|一个 API,接入每个 AI 模型 — Integrate once to route, failover, and meter every major AI model.
All Shanhai Gateway alternatives