Skip to main content

langchain-vaquill

LangChain and LangGraph tools, a toolkit and a retriever for the Vaquill US primary law Data API. Built on the published vaquill Python SDK.

It gives an agent search, citation resolution, section text, amendment history, cited-by, definitions and session laws over US federal and state statutes, regulations, court rules and constitutions.

Install

pip install langchain-vaquill
export VAQUILL_API_KEY="vq_key_..."

Python 3.11 or newer (the vaquill SDK requires it). For the agent example also pip install "langchain-vaquill[agents]" langchain-openai (langchain 1.0 or newer, which provides create_agent).

Cost warning

Almost every Vaquill call spends credits. A search costs 4 credits, a section's text 6, a citation resolve 2, definitions 4. An agent in a loop can spend a lot without anyone noticing, so:

  • Set max_credits on the toolkit and the retriever. It is a hard cap: once reached, paid tools return a message telling the model to stop.
  • Use free_only=True to expose only tools that never spend (vaquill_credit_balance, vaquill_get_pricing, vaquill_statutes_coverage, vaquill_list_boards, vaquill_list_watches, vaquill_extract_citations with its default resolve=false).
  • Every tool description states what it costs, so the model can plan. vaquill_get_pricing returns the live prices.

Agent

from langchain_openai import ChatOpenAI
from langchain.agents import create_agent

from langchain_vaquill import VaquillToolkit

toolkit = VaquillToolkit(max_credits=100)  # reads VAQUILL_API_KEY
agent = create_agent(ChatOpenAI(model="gpt-4o"), toolkit.get_tools())

result = agent.invoke(
    {"messages": [("user", "Is California Penal Code 187 in force, and what does it say?")]}
)
print(result["messages"][-1].content)
print("credits spent:", toolkit.credits_spent)

create_agent replaces the deprecated langgraph.prebuilt.create_react_agent. It returns a LangGraph graph, so checkpointers and streaming work as before. This exact example runs offline against a scripted chat model in tests/test_agent_example.py.

Tool selection

VaquillToolkit(tools=["vaquill_search_statutes", "vaquill_get_statute_text"])
VaquillToolkit(free_only=True)
VaquillToolkit.available_tool_names()

The default is read-only. The watch tools (vaquill_create_watch, vaquill_update_watch, vaquill_delete_watch) change the account and exist only with include_watch_tools=True.

Retriever

from langchain_vaquill import VaquillRetriever

retriever = VaquillRetriever(
    k=3,
    filters={"state": "ca", "corpus_type": ["STATE"], "exclude_repealed": True},
    max_credits=30,
)
docs = retriever.invoke("homicide with malice aforethought")
docs[0].page_content  # section text
docs[0].metadata[
    "citation"
]  # also: id, jurisdiction, sourceUrl, effectiveDate, lastAmendedDate, currentThrough

include_body=True (the default) returns section text and costs about 4 + 6 per row. include_body=False returns the excerpt for the search price only. A call that could push the total past max_credits is refused before any request is sent (vaquill.SpendGuardExceeded).

Configuration

  • api_key= or the VAQUILL_API_KEY environment variable. A missing key fails at construction.
  • client= / async_client= reuse an existing vaquill.Vaquill / vaquill.AsyncVaquill. With a sync client only, async calls run it in a worker thread.
  • Requests carry the User-Agent vaquill-python/<sdk> ... langchain-vaquill/<version>, set through the SDK's default_headers option.

Errors

Tools never raise SDK exceptions or stack traces at the model. They raise ToolException with an instruction: out of credits (stop), bad key (stop), rate limited (wait, retry once), not found (resolve the citation first), bad arguments (fix and call again), spend cap reached (answer with what you have). Anything shaped like an API key or bearer token is removed from messages.

Tests

pip install -e ".[dev]"
pytest

The default suite points the SDK at a local fake HTTP server and makes no live calls. One optional live smoke test (at most 5 credits) runs with VAQUILL_API_KEY=... pytest -m live.

Licence

MIT.

Metadata

Release files for langchain-vaquill 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-vaquill 0.1.0
File Size Uploaded Provenance Actions
langchain_vaquill-0.1.0.tar.gz 33.1 kB With provenance Details for langchain_vaquill-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-vaquill 0.1.0
File Interpreter ABI Platform Actions
langchain_vaquill-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_vaquill-0.1.0-py3-none-any.whl

Total release size: 57.3 kB

Release files / langchain_vaquill-0.1.0.tar.gz

Download URL langchain_vaquill-0.1.0.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
278ea1902eeb16c59c0f5dde24894ca13f597cc4a2e943942860f43b081f2c86
BLAKE2b-256 checksum
How to use checksums
368b2716a9170d20cc3dc94e3693d1aee9380bf18aa92832694294a8ca770d3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / langchain_vaquill-0.1.0-py3-none-any.whl

Download URL langchain_vaquill-0.1.0-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35b28acd5d8a81ea09271b483ae7a5cabe42bd8a05012de595c639edc315eede
BLAKE2b-256 checksum
How to use checksums
214735faa21361d9a448d2b4eb574ab561d99a801720cbb6ad8e9aa0aef02ea7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for langchain-vaquill 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_vaquill-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page