Skip to main content
Grounding means you retrieve the authoritative sections first and give the model their verbatim text. The model then answers only from that text and cites each claim. Every section Vaquill AI returns has a citation, full text, and a link to the official government source, so users can check the answer.
The runnable implementation is in the RAG grounding recipe. It includes the retrieval loop, the prompt, the citation check, and a tool-calling agent variant.

The pattern

1

Retrieve the relevant sections

Send the user’s question to POST /us/statutes/search. Scope it with corpusType (and state for state-scoped corpora) so off-target jurisdictions do not compete for the model’s attention. Each result carries an actId, a citation, an excerpt, and a source URL.
2

Fetch the authoritative text

The excerpt is a ranking preview, not quotable text. Set includeBody: true on the search to attach each hit’s full text on body. Or call GET /us/statutes/section/{actId}/body per section. Both bill the same body price (see what a search costs).
3

Construct a grounded prompt

Give the model the retrieved sections, each labeled with its citation and source URL. Tell it to:
  • answer only from the provided sections,
  • cite each claim by its citation,
  • say it cannot find support when the sources do not cover the question.
4

Link back to the source

Show the answer with its citations, and link each one to the official source URL returned with the section.

Practical guidance

Best practices covers scoping, excerpt, relevanceScore and cost per body.
Pass the body text through untouched. Paraphrasing can shift the meaning.
Keep each passage next to its citation and its source URL (for example htmlUrl, stateHtmlUrl, or govInfoHtmlUrl). The model can then attribute claims, and your UI can show clickable citations.
Check noGoodMatch on the search response before you build the context. When it is true, nothing in the corpus looks on point. Tell the user, and do not give the model weak passages. When it is null, retry the query.Do not drop results below a fixed relevanceScore cutoff. Use the score only to order what you show.
Check that every actId or citation in the model’s answer appears in the set you passed in. Drop or flag anything that does not.
A grounded turn is one search plus one body per section you cite. Cost grows with the sections you cite, not the sections you retrieve. Cache on actId.Read creditsConsumed on the response for what a call actually cost, instead of computing it. It can be lower than the list price, and failed or refunded work bills 0.

RAG grounding recipe

The runnable version: retrieval loop, prompt, citation check, and the tool-calling agent variant.

Best practices

Scope queries, choose a matchType, cache coverage, and handle errors well.
Last modified on November 11, 2026