API vs RAG cost: the short answer
A hosted legal-data API is priced by usage, so it has no upfront build and its cost grows with the queries you run. Building your own RAG pipeline costs an estimated $80k to $270k in engineering time before the first production query (2 to 3 engineers for 4 to 6 months at an assumed $120k to $180k salary each, before benefits), then an estimated $1,450 to $6,600/month in infrastructure. The break-even is simple: a pipeline's fixed monthly cost divided by the API's price per query. At an illustrative $0.10 per query, a pipeline that costs about $13,300 a month all in only wins above roughly 133,000 queries a month.
That is the RAG vs API legal data decision in one paragraph. The rest of this post shows the per-unit math so you can run it against your own numbers.
Reviewed and corrected on 12 October 2026. This is general information, not legal advice.
You ship a feature that needs to answer a legal question grounded in real law, and now you have to decide who stores and indexes millions of pages of statutes and court opinions: you, or somebody else. It usually gets decided on vibes instead of arithmetic. This post does the arithmetic.
You're a developer at a US legal tech startup. Your product needs to answer legal questions grounded in real law. Maybe it's a contract review tool, a compliance checker, or a litigation research assistant.
Either way you need access to US statutes and regulations (and, for some products, court opinions, which come from different sources), and the answers have to be sourced and accurate.
You have two paths.
Path A: Run an in-house Retrieval-Augmented Generation (RAG) pipeline. Pull the source documents, chunk them, embed them, store the vectors, wire up an LLM, and run the whole thing.
Path B: Call a hosted legal-data API for the corpus you'd otherwise build yourself (US statutes, the CFR, state and territory codes), and bring your own LLM layer on top.
TL;DR
- Building a legal RAG pipeline runs an estimated $80k to $270k in engineering time before your first production query, plus an estimated $1,450 to $6,600/month in infrastructure once it's live.
- A hosted legal-data API (US Code, CFR, state and territory codes) is priced by usage, with no upfront build. The per-endpoint credit costs are on the provider's pricing endpoint, so you can price your own workflow.
- The crossover is a formula: fixed monthly cost of the pipeline divided by the API's price per query. At an illustrative $0.10 per query and about $13,300 a month of fixed cost, it is about 133,000 queries per month.
- Three things shift the math under either approach: proprietary documents (you index those yourself regardless), a custom embedding model, and hard data-residency rules.
- When legal research is a feature rather than the whole product, or when you are validating an idea, the fixed-cost estimates below favor a hosted API.
- Your own query volume is the input that turns the crossover estimate into a number for your product, so measure it before you decide.
You are estimating what each live question will cost in a retrieval-augmented legal assistant. Where will most of the per-question cost go?
Part of our legal AI verification and hallucination guide series.
For related verification / hallucination / vendor-trust coverage, see How AI Legal Research Works: RAG, Grounding, and Citations.
Where RAG came from, and what a corpus costs
The idea has a clear birthday. In May 2020 a team led by Patrick Lewis posted a paper called "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks," later accepted at NeurIPS 2020. Their pitch was that language models store facts in their parameters, but "providing provenance for their decisions and updating their world knowledge remain open research problems." Their fix paired a language model with an explicit memory, a dense vector index of Wikipedia, and they reported that these models produced "more specific, diverse and factual language" than the model alone. (Lewis et al., arXiv, 2020.) Notice what the original recipe indexed: Wikipedia, a single, tidy, freely available text. Law is neither tidy nor a single source, which is why the build estimates below run so high.
For a sense of what assembling a legal corpus takes, look at what Harvard did with case law. The Caselaw Access Project, a partnership between Harvard Law School's Library Innovation Lab and the company Ravel Law, spent three years digitizing 627 reporters, about 40 million scanned pages, before launching in October 2018. The lab's director, Andrew Ziegler, told a legal-tech blog: "A project like this should be unnecessary. But many states are still putting stuff in books first." (ABA Journal, October 2018.) That was older, printed case law, and you wouldn't repeat that exact job. It does show how much work sits underneath the polished "ask a question, get an answer" box before any model is involved.
Path A: an in-house RAG pipeline
A legal RAG pipeline is not a weekend project. It means ingesting millions of documents (statute sections, regulations and, if you need them, court opinions), processing them into searchable chunks, and connecting them to a language model that can synthesize answers.
Here's what each piece actually costs.
Infrastructure costs
The numbers below are our own estimates for a pipeline serving a few thousand queries a month, not quotes. Where a provider's list price is cited, it was read on 12 October 2026. Your actual costs will vary with region, reserved-instance commitments, negotiated discounts, and architecture. We've linked official pricing pages so you can run your own numbers.
| Component | Typical Service | Monthly Cost (USD) |
|---|---|---|
| PDF Processing + OCR | AWS Textract / custom pipeline | $250 - $600 |
| Embedding Generation | OpenAI API / self-hosted model | $150 - $400 |
| Vector Database | Pinecone / Qdrant Cloud / Weaviate | $300 - $1,200 |
| LLM API (GPT-4o / Claude) | Per-query inference | $200 - $2,500 |
| Compute (chunking, indexing, orchestration) | AWS / GCP instances | $400 - $1,500 |
| Storage (millions of documents) | S3 / GCS | $150 - $400 |
| Total Infrastructure | $1,450 - $6,600/month |
A few reference points to ground these, all read on 12 October 2026. AWS Textract charges $0.0015 per page (so $1.50 per 1,000 pages) for Detect Document Text in US West (Oregon) on the first 1M pages each month, dropping to $0.0006 after (read from the AWS Price List API for that region). OCR across millions of scanned pages adds up fast.
Pinecone's Standard plan carries a $50/month minimum usage charge, with serverless indexes billed on read units, write units, storage and egress (Pinecone's cost documentation). The vector database line above is our estimate for a corpus of millions of documents, not a Pinecone quote.
On the embedding side, OpenAI's text-embedding-3-small is listed at $0.02 per million tokens (OpenAI pricing). Cheap per document, real across a corpus of millions. LLM inference is the wildcard: on OpenAI's current list, GPT-5.4 mini input costs $0.75 per million tokens and GPT-5.5 costs $5.00, so the model you pick swings your monthly bill several times over.
These ranges reflect moderate scale: a few thousand queries a month against a corpus of millions of documents. The low end assumes batching, spot instances, and smaller embedding models. The high end is fully managed services plus a frontier LLM for generation.
Not in the table: monitoring (Datadog or similar), logging, CI/CD, and on-call. Those add another $200 to $800/month once you're in production (our estimate, like the rest of the table).
What one RAG query actually costs
Per-query, RAG cost is three line items stacked on each other: embed the question, search the vectors, then run the LLM on the retrieved text. Here is a worked estimate for one legal query using OpenAI's list prices read on 12 October 2026. The token counts are our assumption.
| Step | Assumption | Per-query cost (est.) |
|---|---|---|
| Embed the query | ~50 tokens at $0.02 per 1M tokens | ~$0.000001 |
| Vector search | One usage-billed read; small next to the model call | a small fraction of a cent |
| LLM generation, GPT-5.4 mini | ~4,000 input + ~600 output tokens at $0.75 and $4.50 per 1M | ~$0.0057 |
| LLM generation, GPT-5.4 | the same tokens at $2.50 and $15 per 1M | ~$0.019 |
| LLM generation, GPT-5.5 | the same tokens at $5 and $30 per 1M | ~$0.038 |
Retrieval is almost free per query, and the LLM call is nearly all of the marginal cost, which is why the model you choose moves your bill more than any vector-database choice. A cheaper model than the three above would land lower.
Note what this number leaves out: it is the marginal cost of one query on infrastructure that already exists. It does not include the $80k to $270k build, the $1,450 to $6,600/month to keep the corpus indexed and fresh, or the maintenance engineer. The crossover math below folds those back in, because that is where the real RAG pipeline cost lives.
Engineering costs
Infrastructure is the recurring cost. Engineering time is the upfront cost, and it's the one teams underestimate most.
Building a legal RAG pipeline from scratch usually takes:
- 2 to 3 engineers working 4 to 6 months before you have something production-ready (our planning assumption, not a survey figure)
- Experience with NLP, information retrieval, and LLM orchestration
- A real grasp of legal document formats (court opinions arrive in wildly inconsistent PDF layouts, and reporter pagination is its own headache)
Assume $120k to $180k a year in salary per engineer, which is $10k to $15k a month before benefits, payroll tax and equipment (an assumption you should replace with your own). Two engineers for four months is 8 engineer-months, or $80k to $120k. Three engineers for six months is 18 engineer-months, or $180k to $270k. That is where $80k to $270k in engineering time before you serve a single production query comes from.
Your numbers will move with location, seniority, and whether you hire full-time or contract.
That's before maintenance. Models drift, new opinions land daily, chunking strategies need tuning, and the vector index needs periodic rebuilds. Budget at least one engineer at 30 to 50% time on upkeep.
The real cost of "good enough"
A RAG demo that looks right is quick to build. Getting it accurate enough to rely on is where the money goes.
Legal data has specific traps that generic RAG tutorials skip (we go deep on these in our technical breakdown of how legal RAG actually works):
- Citation formats are inconsistent. The same opinion shows up under multiple reporters. Carpenter v. United States is cited as 585 U.S. 296, as 138 S. Ct. 2206, and as 201 L. Ed. 2d 507. Your pipeline has to map all three to one case.
- PDF quality varies wildly. Recent U.S. Supreme Court slip opinions are clean. Older district court orders are often scanned images with rough OCR.
- Legal reasoning is long. A single opinion can run 100+ pages with footnotes, concurrences, and dissents. Naive chunking breaks when the relevant passage spans pages and refers back to earlier paragraphs.
- Freshness matters. The U.S. Courts of Appeals and U.S. District Courts publish new opinions every working day. Your pipeline has to ingest, process, and index them within hours, not weeks.
What the research says about legal RAG
You don't have to take our word that retrieval is only part of the answer. In 2024 Stanford-led researchers published the first preregistered empirical evaluation of AI-driven legal research tools. Their finding was balanced: hallucinations were "reduced relative to general-purpose chatbots," but not eliminated. They also explained why law is hard for retrieval. "In different jurisdictions and in different time periods, the applicable rule or the relevant jurisprudence may differ," they wrote, and "Even similar-sounding text in the correct time and place may not apply if special conditions are not met." (Magesh et al., "Hallucination-Free? Assessing the Reliability of Leading AI Legal Research Tools," 2024.) That is a design problem. A nearest-neighbor search finds text that sounds like the question, and the law cares about which text governs.
A companion paper by several of the same authors looked at the bare models. When asked specific, verifiable questions about random federal court cases, general-purpose language models hallucinated between 58% and 88% of the time, depending on the model. (Dahl et al., "Large Legal Fictions," Journal of Legal Analysis, 2024.) Grounding the model in retrieved text clearly helps, and that's the reason to build or buy a retrieval layer at all. It just doesn't end the verification job.
Developers say the same thing in plainer words. A Hacker News commenter wrote in June 2024: "RAGs do not prevent hallucinations." (threeseed, Hacker News, June 2024.) Both statements are true together: retrieval is the right fix, and it is a partial one. Budget for evaluation either way.
Path B: use a legal data API
Now the other side.
A hosted legal-data API hands you structured access to the U.S. Code, the CFR, federal rules, and state and territory statute codes through HTTP calls, with the ingestion, parsing, and section-level normalization on the provider's side.
You still bring your own LLM layer and your own retrieval logic if you want a "send a question, get an answer" surface, but you skip the corpus engineering for statutes and regulations. Court opinions are a different data source with their own providers, and the hidden-cost sections below that describe opinion pipelines apply to them, not to a statutes API.
Pricing
A hosted legal-data API is priced by usage, with no upfront build. Vaquill AI's API bills in credits per call, and the per-endpoint credit costs are published on its free, unauthenticated pricing endpoint (GET /api/v1/api-credits/pricing), so you can price your own query flow before you sign up. A search plus a text fetch is two calls, so count both when you model cost per question. The pull legal research into your internal app guide walks the integration end to end.
Integration cost
The integration is one HTTP call per step. Here's the code to search the U.S. Code and hand the top hits to your own LLM call. It needs an API key, so it was not run as written in our October 2026 review, but the request fields and the results, citation, actId and excerpt response fields match the live OpenAPI document and a real search run through the MCP tool:
import requests
resp = requests.post(
"https://api.vaquill.ai/api/v1/us/statutes/search",
headers={"Authorization": "Bearer vq_key_..."},
json={
"query": "disclosure of customer records to a governmental entity",
"corpusType": "USC",
"limit": 5,
},
)
for hit in resp.json()["results"]:
print(f" - {hit['citation']} ({hit['actId']})")
# Pass hit['excerpt'], or fetch /us/statutes/section/{actId}/body
# for the full text, to your own LLM for synthesis.
A handful of lines. No chunking logic, no vector database, no embedding model, no PDF parser to maintain for statutes and regulations. The API returns structured sections; the answer-synthesis layer is yours to build (or yours to point at an existing LLM provider). On a test run with this exact query, the top hits were 18 U.S.C. 2703 (Required disclosure of customer communications or records), 12 U.S.C. 3403, 18 U.S.C. 2702, 12 U.S.C. 3402 and 12 U.S.C. 3414.
Compare that to the architecture for a typical legal RAG pipeline:
Every box is a service to run, a failure point to monitor, and a line on your cloud bill.
Legal API vs building a RAG pipeline: the crossover point
The question that actually decides legal API vs building a RAG pipeline: at what query volume does building become cheaper than calling?
Break-even queries per month = the pipeline's fixed monthly cost divided by the API's price per query.
Here's the shape of it using the estimates above. Your real crossover will differ.
DIY pipeline cost (estimated):
- Infrastructure: $4,000/month (about the midpoint of the range)
- Amortized engineering: the low end of the build estimate, $80,000 over 24 months = about $3,300/month (a conservative choice that favors DIY)
- Maintenance engineer (50% time at the assumed salary band): about $5,000 to $7,500/month, call it $6,000
- Total: roughly $13,300/month
That fixed monthly outlay never moves whether you run 1,000 queries or 1,000,000. Usage-based API pricing does the opposite: it starts at zero and rises only with the queries you run. So the lines cross where volume times the API price per query equals the fixed cost.
The price per query is the number you plug in. Use the provider's pricing endpoint, and count every call a question needs (a search plus a text fetch is two). To show how sensitive the answer is, here are three illustrative prices, not any provider's rates:
| Illustrative API cost per question | Break-even against $13,300/month |
|---|---|
| $0.01 | about 1.33 million queries a month |
| $0.10 | about 133,000 queries a month |
| $0.50 | about 27,000 queries a month |
Drop the engineering amortization (assume the team would be idle otherwise) and the fixed cost falls to about $10,000 a month, which moves each break-even down by about a quarter. The order of magnitude is the point: a pipeline only pays off at high, steady volume, and the API's per-query price decides how high.
Hidden costs of the DIY path
The table covers the obvious expenses. These show up later.
Keeping data fresh
US courts publish new opinions every day across the U.S. Supreme Court, the U.S. Courts of Appeals, and the U.S. District Courts, plus state appellate and trial courts. Building the initial corpus is hard. Keeping it current is harder.
You need ingestion for each source, parsers for each format, and a pipeline that runs reliably every day.
When a court site changes its layout (more common than you'd think), your scraper breaks at 2 AM and nobody notices until a user reports stale results.
Multi-court coverage
The Supreme Court and the federal appellate courts are relatively well structured, with clean PDFs and consistent formatting. State trial court records and older district court orders are a different story. Comprehensive coverage across US courts takes years.
Hallucination monitoring
RAG reduces hallucination, it doesn't eliminate it. Your LLM can still misread a passage, conflate two cases, or invent a citation that looks plausible but doesn't exist.
In law that isn't just annoying, it's dangerous, and courts have sanctioned lawyers for filing fabricated citations. You need evaluation pipelines, human review, and a way to track accuracy over time.
That's an ongoing cost in both engineering and operational attention.
Citation normalization
US legal citations are a mess of parallel reporters. The same opinion can appear as:
- 585 U.S. 296
- 138 S. Ct. 2206
- 201 L. Ed. 2d 507
- Carpenter v. United States
Your pipeline has to resolve every form to one canonical case, across U.S., S. Ct., L. Ed., and F.3d reporters. That's a non-trivial NLP problem that needs a maintained mapping database.
What shifts the trade-offs
The numbers above assume a team that needs public statutes and regulations in a search-and-retrieve shape. Several factors move the comparison, and they move it in both directions.
- Proprietary data. A product that searches a company's own contracts, memos, or client files has to index that material itself under any approach. A hosted statutes API covers published U.S. statutes and regulations, so the private corpus is a separate piece of work whichever way the public-law side is sourced.
- Embedding model. A narrow specialty, say ERISA disputes, can benefit from a fine-tuned embedding model, which means controlling the embedding layer. A hosted API returns structured text and leaves the embedding of your own material to you.
- Team capacity. A self-run pipeline carries the upkeep estimated above, at least one engineer at 30 to 50% time. A hosted API removes ingestion and parsing upkeep and leaves the synthesis layer with you.
- Data residency. Some organizations, such as government bodies and firms with strict data policies, need every component inside their own network. That constrains where the vector store and the LLM layer can run, and it applies whichever source supplies the statute text.
- Stage of the product. A product that is still validating demand has a different tolerance for upfront cost than one with measured query volume. API spend scales with the queries you run. A pipeline's fixed cost does not.
- Breadth of coverage. Building a comprehensive statutory database is a multi-year effort. A hosted API provides the U.S. Code, the CFR, and state and territory codes from the first call. The live coverage endpoint lists exactly what is held for each jurisdiction.
Reading the numbers over time
Most teams get more from measuring than from forecasting. Track which queries recur, what accuracy bar your users need, and how many queries you actually process per month. Those three figures, plus the provider's price per query, are what turn the crossover formula above into a number for your own product.
If your measured volume sits well below the break-even, the pipeline's fixed cost is not paying for itself. Far above it, the pipeline's fixed monthly outlay is spread across enough queries to start competing. In between, the answer depends on your team, your data, and how much of your engineering time legal research would take.
Side-by-side summary
Cost figures are estimates. See the breakdowns above for assumptions and reference points.
| Factor | In-House Pipeline | Hosted Statutes API |
|---|---|---|
| Upfront cost | $80k - $270k (est. engineering) | $0 |
| Monthly infra cost | $1,450 - $6,600 (est.) | $0 (pay per call) |
| Marginal cost per query | LLM cost only, roughly $0.006 to $0.04 on the models priced above | The API's per-call price, plus your own LLM call |
| Time to first query | Months (est. 4-6) | A working call from the sample above |
| Coverage | Whatever you build | U.S. Code, CFR, state and territory codes |
| Data freshness | Your responsibility | The provider's refresh cadence |
| Maintenance burden | High (est. 1+ engineers) | Your integration and answer layer |
| Customization | Full control | Within the API's parameters |
| Your own documents | Index them in the pipeline | Index them yourself alongside the API |
| Scales to very high volume | Potentially cheaper at very high steady volume | Linear cost scaling |
The bottom line
A self-run pipeline carries a large fixed cost and ships months later. A hosted API carries a variable cost and ships sooner. Which is cheaper depends on one ratio: the pipeline's fixed monthly cost over the API's price per query. At an illustrative $0.10 per query that break-even is around 133,000 queries a month, and at lower prices it is higher.
Your situation may differ if you already have the team and infrastructure.
Where you land depends on your query volume, your team, and your data requirements. Run your own math and decide.
FAQ
Is an API or a RAG pipeline cheaper?
It depends on volume. A hosted legal-data API is priced by usage with no upfront build, while a RAG pipeline costs an estimated $80k to $270k in engineering plus an estimated $1,450 to $6,600/month before you serve a query. The break-even is the pipeline's fixed monthly cost divided by the API's price per query: at an illustrative $0.10 per query and about $13,300 a month of fixed cost, roughly 133,000 queries a month.
What does a RAG pipeline actually cost to run?
Two numbers matter. The marginal cost of one query is mostly the LLM call: on OpenAI's list prices read on 12 October 2026, about $0.006 with GPT-5.4 mini and about $0.04 with GPT-5.5 for 4,000 input and 600 output tokens (our token assumption), with embedding and vector search close to nothing. The fixed cost is the larger one: an estimated $1,450 to $6,600/month in infrastructure plus a maintenance engineer to keep the corpus fresh.
What is the biggest cost in a RAG pipeline?
For marginal cost per query, the LLM call, by a wide margin. For total cost of ownership at modest volume, the fixed costs: the build and the engineer who keeps it running. Picking a smaller model moves your per-query bill more than any vector-database choice.
For legal data, should I build RAG or use an API?
It depends on what the product needs. Legal research as a feature, an idea still being validated, and a wish for broad statutory coverage from the first call all favor a hosted API on cost and time. Proprietary documents, a custom embedding model, and data-residency rules add work under either approach, because they concern your own material and where it runs. Estimating your query volume against the break-even formula in this post is the most useful next step.
How many queries before building your own RAG pipeline is worth it?
Divide your pipeline's fixed monthly cost by the API's price per query. With the estimates in this post ($13,300 a month, or about $10,000 if you treat the team as a sunk cost), a $0.10 query breaks even at about 133,000 queries a month, or about 100,000 without the engineering amortization. A cheaper API call pushes the break-even higher.
Does a legal API replace the LLM in my stack?
No. A hosted statutes API hands you structured, normalized statute and regulation text. You still bring your own LLM layer to synthesize an answer from that text. It replaces the corpus-engineering half of RAG (ingestion, parsing, chunking, normalization) for statutes and regulations, not the generation half.
Why is embedding and vector search so cheap per query?
Embedding one short query is about 50 tokens, which at $0.02 per million tokens is about a ten-thousandth of a cent, and a single vector read is a usage-billed fraction of a cent. Those steps only get expensive at indexing time, when you embed millions of documents once. Per live query, the cost is the LLM reading the retrieved passages, not the retrieval itself.
Vaquill AI runs a hosted statutes API along these lines, covering the U.S. Code, the CFR, and state and territory codes for primary-text search and retrieval.
For the US statutes, regulations and court rules these laws sit in, see the US primary law API.
New legal AI guides, weekly.
Further Reading
- "We Do Not Train on Your Data": How to Verify the Claim
- AI Law Search Engine vs Keyword Search: Find Case Law Faster
- How to Verify AI Legal Citations Before You File (ABA 512 Checklist)
- ABA Formal Opinion 512 (2024): Generative AI Duties for Lawyers
- Legal Research With No Data Indexing or Human Review: A Confidentiality Checklist
- Are ABA Formal Opinions Binding? What Opinion 512 Means for Your AI Workflow

Co-Founder & CTO
Priyansh leads engineering and AI at Vaquill AI: the pipelines that pull statutes, regulations and court rules from every US jurisdiction's official publisher, and the REST API, MCP server and open dataset that serve them.
