AI Governance Gateway
Project Overview
The strategic goal was simple to state and hard to do: make every AI call from every team flow through one system, subject to the same policy, the same cost control, and the same audit — without slowing anyone down or making them learn a new API.
The gateway proxies the entire Azure AI service surface plus Anthropic, OpenAI/Codex, Cursor, xAI Grok, and Google Gemini behind a single OpenAI-compatible client. Migrating an existing service is a two-line change. Sole architect; roughly 54,000 lines across 581 files.
The Challenge
- Credential sprawl: each product team held its own AI keys and role assignments — the exact thing a breach report lists first
- No cost attribution: nobody could say which project spent what, or stop a runaway loop before it drained a shared quota
- No audit: requests, policy decisions, and denials weren't recorded anywhere tamper-evident
- Vendor lock-in per team: switching or adding a model provider meant every team re-solving auth, retries, and rate limits
Technical Solution
One governance pipeline, four request paths
Synchronous inference, durable async via message queue, multi-agent orchestration, and typed service proxies all pass through the same pipeline: resolve connection → evaluate policy → rate limit → invoke adapter → compute cost → write usage record. There is no path around it.
Multi-vendor by design
An OpenAI-compatible surface with runtime vendor dispatch across five model providers. Transport switches at runtime between a managed AI platform and direct vendor APIs, so a vendor incident is a configuration change, not an outage.
Governed platform stores
Memory, artifacts, chat sessions, a vector-store registry with pluggable RAG backends (four implementations), a web-search provider registry, and a deep-research orchestration — decompose → search and retrieve → verify → synthesize with citations — are all governed resources under the same policy and cost model.
Controls that actually enforce
- Per-project allowlists; allow / deny / fallback policy per model and service, hot-reloaded in ~30 seconds
- Multi-unit rate limiting in Redis — tokens, pages, characters, seconds, and calls
- Per-call USD cost attribution with enforced spend caps as a denial-of-wallet control
- Tamper-evident audit: every request, control-plane mutation, and auth denial HMAC-signed and hash-chained into a write-once store, with a verification endpoint; security events fail closed
Zero-credential authentication
Entra ID tokens with app-role gating on every call. Users sign in interactively; workloads use federated workload identity. There are no API keys anywhere in the path.
AI-safety hardening
Agent sandboxing with secret-scrubbed subprocess environments, egress network policy and instance-metadata blocking, SSRF validation on webhooks, optional content-safety input guardrails, and authenticated MCP transport — mapped to OWASP LLM / Agentic Top 10 and NIST AI RMF, documented in a dedicated threat model.
Three front-ends over one surface
A Python SDK, a terminal CLI, and an MCP server for IDE and agent integration, plus a Next.js 15 admin portal as the human control plane. Retired services return structured migration guidance rather than failing opaquely; restricted capabilities gate behind approval flows.
Deployment
Private AKS, 9 independently scaling pods (HPA plus event-driven autoscaling), all Azure connectivity over private endpoints, secrets via CSI driver and workload identity, GitOps continuous delivery, automated TLS.
Results and Impact
- Three product teams migrated — embeddings, document intelligence, search-index lifecycle, and LLM calls cut over, with their app-side credentials and role assignments then retired from infrastructure
- Every AI call is now attributable to a project, a policy decision, and a cost
- Adding a vendor is one adapter class, not a cross-team project
- Documented in a three-tier package: a 43-page technical design, a 10-page executive summary, and a one-page one-sheet
Key Learnings
Governance only works if the governed path is also the easiest path. The OpenAI-compatible surface and the two-line migration mattered more to adoption than any policy feature. And the moment the gateway existed, the conversation with each team changed from "please rotate your keys" to "delete them."