Status: [UNTESTED] Endpoints found: http://localhost:8000/v1/chat/completions Source: https://github.com/Nishaant-Soni/Switchyard # Switchyard — LLM Gateway / Inference Router A provider-agnostic **LLM gateway**: a reverse proxy that exposes one stable, **OpenAI-compatible** API and routes each request across a fleet of heterogeneous providers. Putting a gateway in the middle turns failover, cost control, rate limiting, caching, and observability into **centralized, swappable concerns** instead of per-client duplication. Runs end-to-end at **zero cost** on a laptop using free provider tiers plus local components. Built from first principles (the LiteLLM / Portkey / Helicone problem space) to demonstrate the design and its tradeoffs — see [`ARCHITECTURE.md`](./ARCHITECTURE.md). --- ## Features - **One endpoint, many backends.** `POST /v1/chat/completions` — existing OpenAI SDK clients work by changing only `base_url`. Send a logical **alias** (`fast`, `smart`, `cheap`) as the model. - **Policy-based routing.** An alias maps to an ordered list of `(provider, model)` targets under a runtime-swappable policy: `priority`, `weighted`, `latency-aware`, `cost-aware`. - **Resilience.** Per-provider circuit breaker (closed → open → half-open), jittered-backoff retry, and **cross-provider fallback** so a dead backend never reaches the client as an error — including fallback *up to first byte* on streaming responses. - **Semantic cache.** Near-duplicate prompts are served from an in-process cache (local embeddings + FAISS ANN search), cutting cost and tail latency at a measured hit rate. - **Per-tenant rate limiting.** Two-dimensional — **request rate and token rate** — in Redis, with a `tiktoken` pre-call estimate reconciled against the provider's real `usage`. - **SSE streaming** end-to-end with natural backpressure. - **Observability.** Prometheus metrics (latency percentiles, cache hit rate, per-provider failures, per-tenant counterfactual cost) in Grafana — and fed back into routing. ## The fleet (free-tier / local providers) All four expose an OpenAI-compatible