Self-Hosted LiteLLM vs Managed LLM Gateway
Weigh engineering costs and compliance risks before choosing self-hosting over managed gateways.

LiteLLM is an open-source proxy. It puts a single OpenAI-compatible endpoint in front of more than 130 providers, gives teams full access to the underlying code, and creates no vendor lock-in by design.
The routing flexibility is real and worth understanding concretely. LiteLLM ships six native modes: weighted pick, latency-based, rate-limit-aware, least-busy, lowest-cost, and a custom Python mode for teams that need to write their own logic. Fallback lists cascade to the next model when one fails. That's a basic reliability layer, and it would take a non-trivial engineering effort to build from scratch.
The feature set is genuinely broad. Virtual keys, budget caps, rate limits, guardrails, load balancing, an admin dashboard, spend tracking across keys, users, teams, models, and providers, with specific support for Vertex AI, Bedrock, and Azure. On a four-instance deployment, LiteLLM self-reports roughly 2ms of median latency overhead against a mock endpoint. That number rises at smaller instance counts; treat it as a floor, not a ceiling.
None of that is the hard part. The hard part starts around day sixty, when the infrastructure you provisioned in an afternoon starts asking for your full attention.
The Engineering Work That Starts After the Initial Deployment
Self-hosting means the team owns the infrastructure outright. LiteLLM's own documentation recommends a multi-instance production deployment: four instances, 4 CPUs and 8 GB of RAM each. That's real infrastructure to provision, monitor, and right-size as traffic patterns shift. Provisioning it once is an afternoon. Keeping it right-sized as load patterns change is a recurring obligation.
Provider API changes are the part teams underestimate most before they've lived through one. When OpenAI ships a new model version, Anthropic updates a schema, or a cloud provider deprecates an endpoint, the self-hosted team absorbs that change on its own upgrade cycle. No one is catching those updates on your behalf.
The sixth routing mode, custom Python, is application code. It gets tested, versioned, and maintained like any other application code, because structurally it is.
The observability gap is the subtler problem. LiteLLM holds the spend and routing data. But producing the view that actually answers a finance stakeholder's question — something like "what did this customer cost us this month across every feature that touched an LLM" — is not a dashboard click. It's a data engineering project. The raw data exists; the pipeline to make it legible for a CFO does not come assembled.
The hidden line item in every build-versus-buy calculation is not the cost of the software. It's the cost of the engineers keeping it running, and the opportunity cost of whatever they're not shipping while they do.
What Spend Visibility Actually Requires and Where Self-Hosted Setups Fall Short
Most organizations discover they don't have adequate spend visibility the first time an invoice comes in over forecast. That discovery happens after the fact, not during planning.
Agentic workflows are the accelerant. A standard chat interaction has a roughly predictable token footprint. A multi-agent workflow — where models are calling tools, spawning subagents, and passing context between steps — can consume an order of magnitude more tokens per task. Teams that budget on per-token rates without accounting for that multiplier are at risk of a cost surprise on their first production deployment.
What granular cost visibility actually means in practice: spend broken down by team, project, API key, model, and provider, updated in real time, not reconstructed from end-of-month provider invoices. LiteLLM's limitation isn't that the underlying data is absent. The limitation is that producing the views a finance or compliance stakeholder needs is a data engineering project, not a configuration option. That distinction matters enormously at scale.
Finance teams are asking questions that weren't anticipated when the gateway was first stood up. "Which team is responsible for the cost spike in the last two hours?" requires real-time allocation data. "What did this product line spend on AI last quarter, by model?" requires attribution logic that most internal tooling was never designed to provide. The demand has outrun the original architecture, and the team inherits the gap.
The Security Surface That Self-Hosted Deployments Must Cover on Their Own
A substantial share of enterprise AI interactions involve sensitive data. Much of it flows through unmanaged channels — employee-facing tools, browser extensions, direct API calls — that bypass corporate controls entirely. The gateway is the only viable enforcement point, and on a self-hosted deployment, engineering builds that enforcement layer themselves.
PII redaction is the clearest illustration of what this actually costs. Provider enterprise tiers don't redact PII from prompts before processing; they structurally can't, because the model needs the prompt text to respond. Redaction must happen before the request leaves your infrastructure. The team builds that pipeline, tunes it, and maintains it as data patterns change. The latency tradeoffs are concrete: regex-based redaction adds under 2ms, an NER model adds roughly 35ms, a remote redaction API call adds roughly 180ms to time-to-first-token. Those numbers will vary based on implementation, but the order of magnitude is representative. Choosing the wrong approach for a latency-sensitive workflow is the kind of mistake that's expensive to undo.
Provider data retention defaults deserve more scrutiny than they typically get. Assumptions about zero-data-retention that aren't confirmed against the actual enterprise agreement terms are risk that hasn't been priced. The terms are documented and reviewable; the problem is that most teams don't read them until something goes wrong.
The regulatory surface is not speculative. GDPR treats sending personal data to an LLM as data processing under EU law. HIPAA treats PHI in a prompt sent to a provider without a Business Associate Agreement as a reportable disclosure. The EU AI Act, with its obligations around risk management, data governance, logging, transparency, and human oversight, applies to high-risk systems on timelines that arrive faster than most engineering roadmaps anticipate.
Audit log requirements complete the picture. Immutability through WORM policies and tamper-evidence through cryptographic hashing are compliance requirements in regulated industries, not storage preferences. A self-hosted team implements and maintains both. RBAC — defining who can call which models with which keys under which budget caps — is infrastructure the team owns, operates, and is accountable for when an auditor asks to see it.
What a Managed Gateway Handles Structurally and What It Trades Away
The structural difference between a managed gateway and a self-hosted proxy is where provider complexity lives. In a managed gateway, API normalization, credential rotation, failover logic, and schema versioning live in the infrastructure layer. They don't live in application code, and they don't consume sprint cycles when a provider updates a schema.
Routing works differently in practice, and the research behind it is worth knowing. RouteLLM's results, presented at ICLR 2025, showed 95% of GPT-4-level performance using only 26% GPT-4 calls, roughly 48% cheaper than a random routing baseline. With data augmentation, the same quality threshold required only 14% strong-model calls, a 75% cost reduction. Whether a specific managed gateway can realize gains at that level depends on its routing implementation; the point is that learned routing is not a marginal improvement over static rules.
In practice, this means defining the goal — cost-optimize this workflow, latency-cap that one — and the gateway enforces it. The team doesn't maintain a Python function that encodes the same intent in a form that breaks when a provider changes its response schema.
Spend visibility by default means the data a finance stakeholder needs is a view, not a pipeline. PII redaction, RBAC, and audit logging are configured, not built. When redaction models update or compliance requirements shift, the vendor absorbs that change.
The tradeoff is real. Teams give up full control of the underlying code. They become dependent on a vendor's reliability, roadmap, and pricing decisions. That dependency is only acceptable under specific conditions: SLA guarantees that are actually contractual, transparent pricing without per-token platform fees layered on top of provider costs, and genuine observability into what the gateway is doing. Opaque automatic model swapping is an unacceptable term in this arrangement. Any vendor offering it should be pressed hard on specifics before signing anything.
How to Read Your Own Team's Situation Against These Two Options
The core question is not which option is better in the abstract. It's what each option actually costs your team, operationally, over a twelve-month horizon. That requires an honest read of your team's actual profile, not the profile you're planning to grow into.
Self-hosted LiteLLM is the right call in specific circumstances. Your team has dedicated platform or ML infrastructure engineers with genuine, sustained capacity to absorb maintenance. Compliance obligations are limited or internal, with no HIPAA, GDPR, or EU AI Act exposure. Routing needs are genuinely idiosyncratic in ways that standard strategies don't address. Engineering time is available and software budget is the binding constraint.
The signals that favor a managed gateway are different in character, and they tend to be legible in retrospect more often than in foresight. If AI usage is growing faster than internal governance can keep up, that lag has a cost, but it shows up in audit findings and finance surprises rather than sprint retrospectives. If finance or security stakeholders need cost allocation or audit evidence that engineering doesn't have time to build, the team is already paying the cost of missing infrastructure, just diffusely, across conversations and escalations that don't map to any single line item. If compliance obligations require enforced PII handling and immutable audit logs, those are present obligations, not features to get to eventually. If agentic workflows are in production or on the near-term roadmap, real-time spend caps are not optional, given what those workflows can do to a token budget in a short period.
Migration cost deserves upfront accounting. Teams that start self-hosted and later need managed capabilities face real switching costs: data migration, integration rework, and the particular tax of evaluating vendors under pressure rather than at leisure. Factoring that in at the start changes the calculus for a lot of teams.
Neither path is permanent, and treating either one as permanent is the actual mistake. What fits a two-person team with a single provider and no compliance exposure will not fit a fifty-person organization running a dozen providers under HIPAA. Concentrate, a fully managed model router that consolidates inference across providers behind a single API and enforces spend limits, redaction, and audit logs without any proxy to host, is one example of the managed side of that spectrum. The decision should be revisited deliberately, on a schedule, not inherited by default when the original context has long since changed.


