r/java • • 28m ago

I built an open-source LLM gateway in Java 25 / Spring Boot 4: failover, caching, quotas and cost tracking behind one OpenAI-compatible endpoint

Most LLM gateways are Python or TypeScript, so I built one on the JVM: 
**Aether Gateway**
 (MIT). Point any OpenAI SDK at it and it handles provider failover (OpenAI, Anthropic, Gemini, Groq, OpenAI-compatible), caching, per-key quotas and per-request cost tracking.

Some JVM details that might interest this sub:

- 
Hexagonal modules,
 with the dependency rules enforced by ArchUnit. The core is JDK-only, and Spring stays in the adapters.
- 
WebFlux only for streaming,
 where cancellation has to reach the upstream call (client disconnects, you stop paying). Virtual threads everywhere else.
- 
Resilience4j
 circuit breakers and bulkheads per provider, plus failover for streams before their first chunk.
- 
Three test layers:
 contract tests shared between the Redis/Postgres adapters and their in-memory counterparts, Testcontainers integration tests, and a Cucumber acceptance suite that runs against both deployment modes.
- 
"Lite mode"
 swaps every store for an in-memory adapter by Spring profile, so the whole gateway runs as one container.

Try it:

docker run -p 8080:8080 -e AETHER_LITE_BOOTSTRAP_API_KEY=aeth_try_me ashishvaghelaa/aether-gateway-proxy:lite

Benchmarks are committed and reproducible, including the misses:
- Cache-hit p95 is 8.9 ms, and failover p99 is 67.92 ms.
- At 2,000 concurrent streams on 2 vCPU, 37% failed. That's not good enough yet.

I'd love feedback on the architecture and the code, and on what would make you actually use it.

GitHub: https://github.com/Ashish-CodeJourney/aether-gateway
Docs and 70-second demo: https://ashish-codejourney.github.io/aether-gateway/
0 Upvotes

1 comment sorted by