You have a RAG pipeline that works. Retrieval is decent, answers are grounded, users are happy. Then someone from legal drops into the channel and asks one question: "Where exactly does the text of our customer contracts go when the model reads it?" And you realize the answer is "to a vendor's API endpoint in another region" — and you have no idea whether that is allowed.
That question, plus a monthly invoice that grows every quarter, is what actually forces the self-hosted LLM vs API decision. Not benchmarks, not vibes about "open models catching up." Two checkable inputs: can the data legally leave your perimeter, and does your token volume justify a fixed GPU bill. Everything else is noise. Below is the order in which to work through it.
Step 1: Sort your queries by what is inside them, not by how many there are
Before any cost math, split your traffic into buckets by data class. Not by feature, not by team — by what the prompt and the retrieved context actually contain. More on the topic: “GDPR (EU Data Protection): What Data Processing Principles Actually Demand — A Hands-On Breakdown”.
Typical buckets in a real pipeline:
- Public or non-sensitive — product docs, marketing pages, open knowledge base. Nothing bad happens if a third party sees it.
- Internal but low-stakes — meeting notes, internal wiki, onboarding material. Leakage is embarrassing, not catastrophic.
- Regulated or contractual — personal data under GDPR, health records, cardholder data, anything under an NDA, source code with trade secrets, financial statements before publication.
Here is the part people miss: in a RAG pipeline the sensitive payload is usually not the user's question. It is the retrieved chunks you paste into the context window. A harmless question like "what is our refund window for enterprise clients?" can drag three paragraphs of a contract into a vendor's logs. If you only classify user input, you will classify the wrong thing. More on the topic: “RAG vs Fine-Tuning: How to Choose the Right LLM Adaptation Method and Avoid Paying for Extra Tokens”.
A quick audit that takes an afternoon: pull a week of production traces, tag each retrieved chunk by source document class, and count what share of your requests carry at least one regulated chunk. In many enterprise assistants that share is small but non-zero — and a non-zero share is what decides the architecture, not the average.
Step 2: Answer the legal question with a document, not an opinion
"May this data leave the perimeter" is not a technical judgment. It is answered by your contracts, your regulator, and your customers' auditors — and the answer is often "partly."
What to check before you touch infrastructure:
- Your customer contracts. Enterprise deals increasingly carry clauses about subprocessors and where data is processed. Sending text to a US-based API vendor may breach a clause you signed two years ago and forgot.
- The applicable data protection regime. Under GDPR, transferring personal data to a processor outside the EEA requires a valid transfer mechanism, and the processor must be listed. The same logic applies in other jurisdictions with their own rules — the specifics vary by country, so this is a conversation with counsel, not with a blog post.
- Sector rules. Card data brings PCI DSS obligations; health data brings its own regime. If your retrieved chunks touch those categories, the vendor's standard data processing agreement may not be enough.
- The vendor's actual retention behavior. Many managed APIs offer zero-retention or no-training options on enterprise tiers. That changes the calculus — but it is a contractual commitment, so get it in writing rather than assuming the default.
If the honest answer is "this data cannot go to a third party at all," you are done deciding for that slice: it runs on infrastructure you control. Everything else continues to Step 3.
One nuance worth knowing: the same reasoning applies to your vector store and embedding calls, not only to the generation model. Embeddings of sensitive text are derived from sensitive text.
More on the topic: RAG Data Residency Checklist: How to Decide If Embeddings Can Leave Your Perimeter. More on the topic: “Building RAG Systems: Chunking, Hybrid Search and Reranking in Real Production Pipelines”.
Step 3: Do the volume math — and do it honestly
The cost comparison most teams get wrong is the one they run on average traffic. Fixed GPU cost versus per-token cost is a break-even problem shaped by your load curve, not by your monthly total.
Work through it with a concrete example. Imagine a support assistant handling 40,000 queries a month, each with roughly 3,000 input tokens (system prompt plus retrieved chunks) and 400 output tokens. That is about 120M input and 16M output tokens monthly.
On a managed API at, say, $2.50 per million input tokens and $10 per million output tokens, that comes to roughly $300 + $160 = about $460 a month. Now price self-hosting: a single modern GPU instance capable of serving a mid-size open-weights model at acceptable latency runs in the high hundreds to low thousands of dollars a month on a cloud provider, before you count the engineer who owns it. At 40k queries, self-hosting loses badly. More on the topic: “Google Cloud Architect — Professional (ACE + PCA): A FinOps Walkthrough of GCP Cost Optimization, Committed Use Discounts, and Compute Engine Rightsizing”.
Scale the same pipeline to 2 million queries a month and the API bill lands in the tens of thousands of dollars while the GPU bill barely moves — now self-hosting wins, provided utilization stays high. The crossover is somewhere in between, and it depends on model size, quantization, and how much of the GPU you actually keep busy.
| Your situation | What usually wins | Why |
|---|---|---|
| Low volume, spiky traffic | Managed API | You pay per token; idle capacity costs nothing |
| High, steady volume | Self-hosted LLM | Fixed GPU cost amortizes across millions of tokens |
| Data cannot leave the perimeter | Self-hosted LLM | Legal constraint overrides cost |
| No MLOps capacity | Managed API | Ops staff is the hidden fixed cost |
Step 4: Count the costs that do not appear on the GPU invoice
This is where optimistic self-hosting business cases die. The GPU rental is the visible line item; the rest is what your team discovers in month three.
- Ops time. Someone has to own model upgrades, CUDA and driver versions, vLLM or TensorRT-LLM tuning, autoscaling, monitoring, and the pager rotation when inference latency spikes at 2 a.m.
- Evaluation and regression testing. Every time you swap a model or change quantization, retrieval quality and answer quality shift. You need an eval harness to catch that — a managed API vendor does this for you on their side.
- Redundancy. A single GPU is a single point of failure. Real availability means at least two nodes, which doubles the fixed cost.
- The idle tax. Provisioned capacity is paid for whether queries arrive or not.
If you have no MLOps capacity to spare, this list alone usually settles the decision — you will run a fragile self-hosted setup that costs more in engineer hours than the API bill it replaced. That is a common and expensive mistake: teams self-host for cost reasons, then discover the true cost is an engineer at 30% allocation plus a worse reliability story than the vendor's.
More on the topic: FinOps — Cloud Cost Optimization: How to Manage Cloud Costs Like a CFO (and Stop Overpaying).
For a sense of what a production-grade deployment actually demands beyond the model weights themselves, the operational surface is larger than it looks.
More on the topic: Production ML (MLOps): Deploying ML Models to Production — Myths and Reality.
Step 5: Consider the split — most teams do not need one answer
The framing "self-hosted versus API" assumes a single pipeline. In practice the winning architecture is often both, routed by data class:
- Regulated chunks go to a self-hosted open-weights model on your own infrastructure.
- Public and internal chunks go to a managed API, where you get frontier quality at per-token prices.
This works because the sensitive slice is usually a minority of traffic. You pay for a modest self-hosted footprint sized for that slice, and keep the cheap, high-quality path for everything else. The routing decision happens after retrieval, based on the document metadata you already store.
The catch: two paths mean two evaluation suites and two prompt sets. If your team is two people, that overhead may eat the savings — in which case pick one path and accept its trade-off.
Step 6: If you self-host, pick the model for your task, not the leaderboard
A self-hosted RAG pipeline does not need the biggest open-weights model. It needs one that fits your GPU budget at your latency target and answers your domain questions well. A mid-size model at 4-bit quantization on a single GPU will often beat a larger model that forces you onto four GPUs and pushes p95 latency past what users tolerate.
Practical sequence: benchmark two or three candidate models on your own eval set built from real queries, measure tokens per second at your target concurrency, then size the hardware from that. Not the other way around — buying GPUs first and hunting for a model that fits is how teams end up with a cluster running at 20% utilization.
And keep the retrieval side honest regardless of who runs the model. A weak retriever makes even a frontier model look bad, and swapping models will not fix it.
More on the topic: Vector Databases — From Search to RAG: Why Your RAG Chatbot Gives Wrong Answers and How to Fix Retrieval.
How this looks when you actually decide
A team with a customer-facing assistant on public documentation, spiky traffic, and no dedicated ML engineer should stay on a managed API and stop feeling guilty about it. A bank running contract analysis over documents that legally cannot leave its environment should self-host the generation step and accept the ops burden as the price of compliance. Most teams sit in between and end up with a routed pipeline.
If you want a single sentence to carry into the meeting: let the data classification eliminate options, then let the volume math pick from what remains. Sensitivity tells you what is allowed; volume and ops capacity tell you what is affordable. Run the two filters in that order and the self-hosted LLM vs managed API question stops being a debate about model quality and becomes an engineering decision you can defend with a spreadsheet.