arXiv:2610.35509cs.DCOct 2026

Manuscript Offprint

arXiv:2610.35509

Governing Enterprise AI Traffic at Scale: Design and Operation of a Policy-Driven, Multi-Vendor LLM Gateway on Envoy

Mithun Sasidharan, Srinivasan Manoharan, Rupesh Thakur, Abhinav TK, Ashwin Hegde, Anand Gautam

Abstract

Large organizations now consume large language models (LLMs) from several vendors at once, and each vendor brings its own API dialect, credential model, streaming protocol, pricing and release cadence. Integrated directly, this heterogeneity yields credential sprawl, format lock-in, unbounded spend and inconsistent governance. We present the design and production operation of the Cosmos LLM Gateway, the governed entry point for enterprise LLM traffic at PayPal. The gateway is built on Envoy and splits work by latency profile: I/O-bound control decisions (authentication, credential brokering, policy and budget evaluation) run in an out-of-process external-processing service, while latency-sensitive payload work (wire-format translation, token metering and prompt-cache shaping) runs in-proxy as a Rust WebAssembly filter, so that, by default, streamed response body chunks never wait on an out-of-process call. Models, providers and prices are largely a validated data model rather than code. Governance is declarative policy evaluated by Open Policy Agent and managed through a control plane with role-scoped authoring for platform and business-unit administrators, approval workflows, scheduled activation, limited-access model releases, cohort-based pilots, shadow-mode rollout, configurable usage notifications and versioned policy-bundle distribution. For use cases that require it, a data-loss-prevention layer that combines pattern rules with an internally hosted detection model can block, redact or reversibly pseudonymize detected sensitive content before it reaches a provider. Every spend scope is a view over per-model usage counters, so a new budget applies to spend already recorded in its window without data migration, and every governed request is designed to yield one deduplicated usage record in the analytics warehouse. As of September 2026, the gateway serves more than 12,000 developers and hundreds of business use cases, including real-time voice support with more than 2,000 concurrent calls. It handles millions of requests and roughly 200 billion tokens per day across more than 100 models from multiple providers, at 99.999% availability to business. In a benchmark of the core request path against a synthetic upstream, it adds a median of 4 ms and a p99 of 11 ms of overhead at more than 2,200 requests per second on two 4-vCPU instances, with no failed requests across the tested range. We report the architecture, the policy model, an evaluation, and the lessons we would carry to any enterprise standardizing access to multiple AI providers.

Keywords: LLM gateway, AI governance, Envoy, ext_proc, WebAssembly, policy as code, Open Policy Agent, data loss prevention, FinOps, multi-vendor routing, observability.

1 Introduction

Generative AI quickly became a production dependency at PayPal. Engineers use agentic coding tools daily; product teams ship AI-assisted features; and customer-facing systems, including real-time voice support, depend on frontier models being available, governed and affordable. The models these workloads need come from several vendors simultaneously, and the best model for a task can change on a timescale of weeks.

The obvious way to consume these models is for each application to integrate each vendor directly: hold the vendor's key, adopt its request format, handle its streaming semantics, and track its spend locally. That approach works for one team and one model. It does not survive an organization of thousands of engineers and hundreds of production workloads spanning several major providers. Direct integration fails along four compounding axes:

• Credential sprawl. Long-lived vendor keys proliferate across applications, with no central place to scope, rotate, attribute or revoke them, and no reliable link from a call to the human who authorized it.

• Format lock-in. An application written against one vendor’s API cannot adopt another vendor’s model without code changes, so model choice, regional placement and failover become engineering projects rather than configuration.

• Ungoverned spend. Cost accrues per key and per vendor, with no organization-aware budgets, no early warning and no lever for business-unit leadership.

• Uneven governance and visibility. Each integration authenticates, logs, rate-limits and protects data differently; security and finance have no single plane on which to ob-serve or control AI traffic.

This paper describes how we addressed these failure modes behind a single layer, the Cosmos LLM Gateway. Beyond a unified API and data plane, the system comprises a full governance control plane, a policy-as-code decision engine, a platform-identity service attested by corporate single sign-on (SSO), a durable usage-attribution pipeline and inline data-loss prevention (DLP). This paper documents the system as it now operates.

Contributions. We make the following contributions:

  1. A two-tier Envoy architecture that runs I/O-bound governance out of process and streaming translation in process, joined by an explicit, contract-tested handoff (section 5).

  2. Models, routing and pricing as validated data: a registry whose loader enforces a serviceability invariant, and a control-plane onboarding lifecycle that takes a model from staged to generally available without a deployment (sections 6 and 10.1).

  3. A canonical intermediate-representation (IR) translation layer that needs one codec per wire format instead of one converter per format pair, with fast paths that are lossless for client content and gateway-side prompt-cache shaping (section 7).

  4. A layered access and spend policy model: organization-anchored model restrictions, business-unit controls, and budgets whose scopes are views over per-model counters keyed by immutable model identifiers, which makes them retroactive within a window and migration-free. Policies are evaluated by a pure decision function separated from side effects (section 9).

  5. A governed policy lifecycle for platform and business-unit administrators: approvals, scheduled activation, pilots with tier ladders, shadow-to-authoritative rollout, threshold notifications and versioned bundle distribution with last-known-good semantics (section 10).

  6. A durable, priced, per-request usage record that drives chargeback and analytics, alongside the per-model counters that drive budgets (section 11), together with production evidence, an overhead benchmark and the lessons we would carry to similar systems (sections 13 and 14).

The gateway governs which models an AI client may call. A companion platform, the Cosmos.AI MCP Hub [23], governs which tools it may reach over the Model Context Protocol [14]. Together they form the access and control plane for enterprise AI at PayPal.