Show HN: ShanHaiGateway – multi-upstream LLM gateway in Go github.com · 3 points...
Show HN @show
Show HN: ShanHaiGateway – multi-upstream LLM gateway in Go github.com · 3 points · 1 comments · HN thread
TL;DR ShanHaiGateway is a self-hosted Go gateway that pools several upstream LLM providers behind one OpenAI-compatible endpoint, with weighted round-robin routing, session affinity for prefix caching, error-class-driven cooldowns, and a quota-window sidecar. The author says it runs in production at about 1 billion tokens a day with a monthly cash bill of roughly ¥170, mostly from free and promotional credit pools; the README is in Chinese and English. The single comment is the author's own list of links.
- Routes requests across multiple upstream accounts with SWRR weighted round-robin, with a fallback chain isolated from the primary pool.
- Pins requests from the same job (X-Job-Id, falling back to X-Session-Key) to one backend; the author reports prefix-cache hit rate rising from 27% to 51% (peak 69%).
- Classifies upstream errors: 403/429 get exponential cooldown from 5 minutes up to 4 hours, queue waits up to 60s when saturated, and client disconnects are not counted as backend failures.
- Includes a quirk layer for provider-specific error bodies and usage keys, a SQLite capture store with automatic redaction, hot-reloaded backends.json, and a Python sidecar that removes backends whose quota windows are exhausted.
- Claims a production load of 20 billion tokens per month for about ¥170 in cash, with the author's own caveats that free-credit availability fluctuates and the price is promotional.
Discussion The thread is essentially a single post by the author pointing to the official site, source repository and English README, so there is no real community discussion yet. The mood is neutral and promotional, and no outside commenter has engaged with the cost claims, the free-credit pooling approach or the architecture.
Links from the comments
- Official bilingual site (English), with the quota command center numbers the author cites
- Source repository with docs and issue tracker
- English README
#llmGateway #golang #openaiCompatible #loadBalancing #selfHosted