DistillQL is a Python package that sits between your AI agent and your databases. It drafts what your company's terms mean from the queries people already run, hands the agent that page, and runs every query read-only as the person asking.
Register interest"What was net revenue in August?"
The agent gets the schema: every table and column, and nothing about what they mean.
Nothing says what net revenue is
The agent writes a query and chooses a definition on its own.
A plausible wrong number
A database server runs it as a shared service account.
Every question sees all the account can
Every row returns into the conversation and the agent reads off a figure.
No record of what ran, or why
The same question, from the same person, in the agent they already use.
Nothing new to learn
DistillQL hands over the definition, the tables it uses and the report that already computes it.
Meaning your team approved
The agent writes the query from that definition. DistillQL checks it: one read, known columns, defined terms.
Undefined means "undefined", not a guess
DistillQL runs it as the person asking, on every database it touches, within a cost cap.
Your own row filters and grants apply
The rows stay in DistillQL. The agent gets a summary and the record of what ran; it can propose a good answer for your team to keep.
Every answer shows its work
DistillQL is one server with five tools, standing where the catalog server and the database server would be. The agent still writes the SQL. Each stage below says what DistillQL does there, with an example from the synthetic marketplace we test on.
import distillql gives the same five functions and the engine underneath them.pip install distillql, point it at your databases, run the crawl. Our ten-table test database crawls in under a second; a few hundred tables take minutes.The same server in each. Ollama runs the model, not the agent, so it pairs with an agent that speaks MCP; goose is one.
net revenue
Service fees minus referral credits, by month.
31 runs of rpt_finance_monthly agree
3 ad-hoc queries leave the credits out
fees summed, credits left out: 6% high and plausible
matches the finance report
If definitions already live in dbt metrics, a semantic layer, Snowflake Semantic Views or a catalog such as OpenMetadata, DistillQL reads those first and mines history only for what they leave out: one set of definitions, not two. On Snowflake alone, Cortex Analyst does part of this inside Snowflake; DistillQL does it over Postgres and the warehouse together, in the agent you already use.
| renter | region | GMV |
|---|---|---|
| Halden Labs | EU | 48,200 |
| Oriel AI | US | 44,910 |
| Mistvale | EU | 31,075 |
| Tanager | APAC | 29,660 |
| Northbeam | US | 27,300 |
| Quillon | US | 22,480 |
| renter | region | GMV |
|---|---|---|
| Halden Labs | EU | 48,200 |
| Mistvale | EU | 31,075 |
| 4 rows outside EU never read. The filter is Postgres's own, applied because the query arrived as her. | ||
distillql.yaml names each database and how to sign in as the person, the row and byte caps, and the one folder write may put files in. No credentials go anywhere else..distillql/context.yaml is the crawl's output: every drafted definition, join path, metric and repeated report, each with the queries it came from, a confidence, and a status of drafted or verified. Plain YAML; your team can edit it, diff it, keep it in git.pg_stat_statements; Snowflake in its query history. DistillQL reads what is already there. It does not install anything in your database..distillql/records/, and writing verified queries back into the context file, are the next build; both are small.write saves one to a named table or a file in the write folder; nothing else leaves.Nothing is sent anywhere. Two files on your disk, and the database you already have.
| Right answers | Cost per question | Tokens per question | |
|---|---|---|---|
| AI today: the schema and a SQL tool, guessing what the terms mean | 77% | $0.035 | 19,669 |
| DistillQL: default settings | 95% | $0.022 | 17,835 |
| DistillQL: enhanced with human-in-the-loop definitions | 100% | $0.021 | 16,441 |