An AI gateway is usually pitched as a router. Its real job is governance: cost control, security and audit. This project builds four of those controls into one LiteLLM gateway, each with a working demo.
The problem
When every service calls LLM providers directly, each one holds its own API key, has its own retry logic and logs in its own format. Nobody sees spend until the invoice arrives, and PII handling depends on which team wrote the code.
What I built
Cost governance: token budgets per team, rolled up to an org, checked before the provider call. A custom_auth hook maps a Cognito JWT to a LiteLLM identity. A scripted runaway agent loop gets cut off with HTTP 429 once the team budget runs out
Security at the edge: Microsoft Presidio as a guardrail that masks names, emails and card numbers before the prompt reaches the provider
Routing and failover: simple prompts go to cheaper models, and a failed provider call is retried on a healthy backup without the caller noticing
Audit trail: every call, allowed or rejected, traced to Langfuse and tagged with user, team and org ids taken on the server side, so callers can't forge them

AI Gateway (LiteLLM) - Amazon Bedrock, OpenAI, AI Agents
Stack
Python, LiteLLM, Amazon Cognito, Postgres, Microsoft Presidio, Langfuse, Docker
0 likes · 0 views · Dec 1, 2026
A LiteLLM gateway that enforces team and org token budgets, masks PII before it leaves the network, routes by cost with failover, and audits every call.