Prism
Teams that scale past calling a provider directly from the app run into unpredictable cost, no visibility into failures, PII/prompt-injection exposure, and no resilience when a provider degrades — usually all at once.
Prism is a self-hosted, multi-provider LLM gateway that sits between applications and providers — OpenAI, Anthropic, self-hosted Ollama — behind one OpenAI-compatible endpoint: a one-line base_url swap, no other code changes. It adds request cost tracking, automatic provider failover through a hand-rolled circuit breaker, PII and prompt-injection guardrails, exact-match Redis caching, and observability through Prometheus, Grafana, and OpenTelemetry tracing. It runs locally under Docker Compose and was load-tested on one machine against local Ollama and mock OpenAI/Anthropic providers — it is not a production deployment.
Two branches aren't drawn above: an exact cache hit bypasses straight from Cache lookup to Response at $0 cost, and a provider failure retries the next provider in the router chain. Both are shown in the full diagram below.
Postgres, Redis, and Jaeger are three independent connections from App, not a chain. Full topology, including exact connection labels (SQL, cache + rate limit, OTLP spans), is in the diagram below.
Local benchmark results
Measured with Locust on a single machine (one uvicorn process) using local Ollama and mock OpenAI/Anthropic providers. These describe this local setup, not production traffic or throughput on other hardware.
What broke
Load testing found a real bug: the rate limiter and exact cache each opened a new Redis connection per request instead of reusing a pool. At roughly 300 req/s that meant hundreds of new connections a second — Redis started closing them under the churn, and the error rate hit 77%. Fixed with one shared module-level Redis client; the failure rate dropped to 0% in the same test afterward.





Stack
Python / FastAPI / PostgreSQL / Redis / Docker Compose / Prometheus / Grafana / OpenTelemetry / Jaeger / Ollama