{"slug": "i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including", "title": "I built an open-source LLM gateway for the JVM, and measured everything, including where it falls short", "summary": "A developer released Aether Gateway, an open-source (MIT) self-hosted LLM gateway written in Java 25 and Spring Boot that exposes an OpenAI-compatible API for provider failover, caching, per-key budget control and cost tracking. Benchmarks committed to the repo show 6.24 ms p95 overhead on cache misses, 8.9 ms p95 cache-hit latency, 67.92 ms p99 failover across 100 injected outages, and zero broken streams in 1,000 during Kubernetes rolling updates, while a 2,000-concurrent-stream test on 2 vCPU / 4 GB missed its target with 37% failures. On a labelled set of 502 prompts, embedding-only semantic caching at a 0.94 threshold returned wrong answers for 28% of tricky pairs, so the feature ships off by default behind a guard that checks numbers, units, dates, entities, negation and opposites.", "body_md": "Most teams calling LLMs end up writing the same plumbing again and again: retry and fall back to another provider when one is down, cache repeated questions, stop one API key from burning the monthly budget, and work out what each feature actually costs.\n\n**Aether Gateway** is my open-source (MIT) answer to that. It's a self-hosted gateway written in Java 25 / Spring Boot, and it speaks the OpenAI API, so adopting it is a one-line change:\n\n``` python\nfrom openai import OpenAI\n\nclient = OpenAI(base_url=\"http://localhost:8080/v1\", api_key=\"aeth_try_me\")\nreply = client.chat.completions.create(\n    model=\"claude\",  # a route alias: Aether decides which provider serves it\n    messages=[{\"role\": \"user\", \"content\": \"Why use an LLM gateway?\"}],\n)\ndocker run -p 8080:8080 -e AETHER_LITE_BOOTSTRAP_API_KEY=aeth_try_me \\\n  ashishvaghelaa/aether-gateway-proxy:lite\n\ncurl http://localhost:8080/v1/chat/completions \\\n  -H \"Authorization: Bearer aeth_try_me\" -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"echo\",\"messages\":[{\"role\":\"user\",\"content\":\"hello\"}]}'\n```\n\nYou get `Echo: hello` with `X-Aether-Cache: MISS`. Send it again and you get `EXACT_HIT`. Lite mode keeps everything in memory, so there's no Postgres, Redis or model download. Add `-e ANTHROPIC_API_KEY=...` (or an OpenAI or Gemini key) to talk to a real model. For production, the full stack adds durable storage, semantic caching, Grafana dashboards and Kubernetes manifests.\n\n`X-Aether-Cost-USD`, `X-Aether-Provider` and `X-Aether-Failover-Chain` headers tell you who answered and what it cost. Streams are billed at the provider's reported token usage, not an estimate.\nEvery number in the README comes from a committed run you can reproduce with `make bench`, including the ones that missed their targets:\n\n|  | Result | \n|---|---|\n| Gateway overhead on a cache miss, p95 | 6.24 ms | \n| Cache-hit latency, p95 | 8.9 ms | \n| Failover to a healthy provider, p99 (100 injected outages) | 67.92 ms | \n| Broken streams during real Kubernetes rolling updates | 0 of 1,000 | \n| 2,000 concurrent streams on 2 vCPU / 4 GB | 37% failed ( **target not met** ) | \n\nSemantic caching sounds like free money: if someone asks a question similar to an earlier one, return the earlier answer. The trouble is that \"similar\" isn't the same as \"the same question\". A sentence-embedding model sees \"Is aspirin safe during pregnancy?\" and \"Is aspirin **not** safe during pregnancy?\" as near-identical.\n\nOn my labelled set of 502 prompts, embedding similarity alone (threshold 0.94) gave a **wrong cached answer for 28% of the tricky pairs**. Aether adds a cheap guard on top. It needs no network calls and compares numbers, units, dates, named entities, negation and common opposites. With it:\n\nSo semantic caching ships **off by default**, the docs say exactly why, and lowering the threshold waits for a proper held-out test set. A cache that's fast but occasionally wrong isn't a cache I'd want in front of real users.\n\nMost LLM gateways are Python or TypeScript. That's fine, but plenty of teams run their infrastructure on the JVM and want a gateway they can read, debug, profile and run with the tools they already know. Aether is a hexagonal Spring Boot codebase with its architecture rules enforced by ArchUnit, so it should be approachable to change.\n\nIf you need the widest provider coverage today, LiteLLM and Portkey are more mature, and I say so in the README.\n\nThe next items are a typed JVM client / Spring Boot starter and a held-out evaluation set for semantic caching. What would really help:\n\nIf it's useful, a ⭐ on GitHub helps other people find it.\n\nGitHub: [https://github.com/Ashish-CodeJourney/aether-gateway](https://github.com/Ashish-CodeJourney/aether-gateway)\n\nDocs and demo video: [https://ashish-codejourney.github.io/aether-gateway/](https://ashish-codejourney.github.io/aether-gateway/)\n\nBenchmarks: [https://github.com/Ashish-CodeJourney/aether-gateway/blob/trunk/BENCHMARKS.md](https://github.com/Ashish-CodeJourney/aether-gateway/blob/trunk/BENCHMARKS.md)", "url": "https://wpnews.pro/news/i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including", "canonical_source": "https://dev.to/ashish-codejourney/i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including-where-it-falls-51mk", "published_at": "2026-11-27 19:28:32+00:00", "updated_at": "2026-11-27 19:44:59.908621+00:00", "lang": "en", "topics": ["large-language-models", "ai-infrastructure", "ai-tools", "developer-tools", "mlops"], "entities": ["Aether Gateway", "Ashish Vaghela", "Spring Boot", "Java 25", "LiteLLM", "Portkey", "GitHub", "Anthropic"], "also_reported_by": [], "takeaway": "Embedding-only semantic caching at a 0.94 similarity threshold returned wrong cached answers for 28% of tricky prompt pairs, so Aether ships it off by default behind a guard that compares numbers, units, dates, entities, negation and opposites.", "recommendation": {"advice": "Keep semantic caching off or behind a negation/entity guard until you have a held-out test set; embedding similarity alone mis-cached 28% of tricky pairs in the source's 502-prompt evaluation.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including", "markdown": "https://wpnews.pro/news/i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including.md", "text": "https://wpnews.pro/news/i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including.txt", "jsonld": "https://wpnews.pro/news/i-built-an-open-source-llm-gateway-for-the-jvm-and-measured-everything-including.jsonld"}}