Skip to main content
Turn a user question into a grounded, citable answer. You retrieve the governing sections from Vaquill, pull their full text, and pass that text to an LLM in your stack with strict instructions: answer only from the provided sources, cite every claim, and link back to the official government source. This is the classic retrieve-then-ground (RAG) loop, and it is the single most reliable way to keep a legal assistant from making things up. Endpoints used: POST /statutes/search (retrieve), GET /statutes/section/{actId}/body (full text).
Vaquill provides the authoritative text and the source links. The LLM in your stack does the reasoning. Vaquill does not replace a lawyer or a licensed research service, and every answer should carry a link back to the official government text so a reader can verify it.

The pattern in four steps

1

Retrieve candidate sections

Send the user question to POST /statutes/search. Scope the search with corpusType and state when you know them (for example USC for federal statutes, or STATE with state: "ca" for California). Take the top few results.
2

Fetch the full text of each section

Search returns an excerpt (up to 500 chars). That is enough to rank, not to ground on. For each result you want to cite, call GET /statutes/section/{actId}/body to get the complete plain text.
3

Build a grounded prompt

Assemble a prompt that contains the retrieved sections, each labeled with its citation and its official source URL. Instruct the model to answer only from those sources, to cite each claim, and to say it cannot find the answer if the sources do not support one.
4

Answer with links back to the source

Return the model’s answer plus the list of cited sources, each linking to the official government text (htmlUrl, stateHtmlUrl, or govInfoHtmlUrl).

Step 1 and 2: retrieve, then fetch full text

A trimmed search result looks like this. Note the actId (used to fetch the body), the citation, and the source URLs.

Step 3 and 4: build the grounded prompt and answer

The prompt is where grounding happens. Give the model the retrieved text, a stable label per source, and rules it cannot skip: answer only from the sources, cite by citation and link, and refuse when the text does not support an answer.
Python
Ground on the full section text from /body, not on the excerpt from search. The excerpt is capped at 500 characters and is meant for ranking, not for quoting. Passing only excerpts to the model invites partial or misleading answers.

Why this holds up

Because the prompt forbids outside knowledge and every source carries a citation plus a link, the model’s claims are traceable. A reader can click the official government URL and confirm the text. If retrieval returns nothing relevant, the model returns the refusal string instead of inventing law.
When you know the question is federal, pass corpusType: "USC" or "CFR". When it is about one state, pass corpusType: "STATE" with the two-letter state code. Tighter scope means the top results are more likely to be the governing sections, which makes the grounded answer more precise. Omit both to search the whole corpus.

Grounding LLMs

The concepts behind grounding and why it prevents hallucinated law.

Statute lookup chatbot

A simpler Q&A loop built on the same retrieve-then-ground pattern.

Resolve a citation

Turn a citation string into authoritative, verified text.

Vaquill MCP server

Give an AI agent these same tools over MCP.