AI Gateway: Designing for Regulated Enterprises
I've been looking into a specific architecture called Aegis Gateway that solves this by making compliance a structural requirement rather than a preference. The core idea is a strict, non-negotiable pipeline where policy filtering happens before anything else.
The "Fail-Closed" Architecture
The workflow follows a rigid sequence: Catalogue → Policy Engine → Ranking → Fallback.
The Policy Engine acts as a hard gate. If a model doesn't meet the data classification or regional residency requirements, it is stripped from the list immediately. The Ranking stage only sees "eligible" models; it literally cannot "resurrect" a non-compliant model just because it has lower latency or higher quality.
Here is a look at how that policy evaluation is handled in the logic:
def evaluate(self, model: ModelSpec, ctx: RequestContext) -> list[str]:
"""Return the list of violated rules (empty list = eligible)."""
reasons = []
if ctx.task_type not in model.capabilities:
reasons.append(f"model does not support task '{ctx.task_type.value}'")
if model.provider not in unit["approved_providers"]:
reasons.append(f"provider '{model.provider}' is not approved "
f"for business unit '{ctx.business_unit}'")
if req_level > CLASSIFICATION_LEVEL[model.max_classification]:
reasons.append(f"model is certified only up to "
f"{model.max_classification.value} data")
# ... region residency, restricted→private, availability
return reasonsWhy this works for LLM agents
In a complex AI workflow, you often have multiple agents hitting different models. By implementing this as a gateway, you move the governance logic out of the application code and into the infrastructure.
- Hard Gates: Policy filtering happens first. No exceptions.
- Soft Optimization: Ranking (cost/latency/quality) only happens among the survivors of the policy gate.
- Controlled Fallback: If the primary model fails, the system only falls back to other eligible models. If the list is empty, the request fails.
It is better for a request to return an error than to leak PII to an unapproved provider. This approach transforms compliance from a "best effort" check into a technical guarantee.