WrenAI: Talk to Your Database, Keep Your Data at Home
"Chat with your data" is the most over-promised sentence in enterprise AI. WrenAI's answer is a semantic layer that actually understands your business — and a deployment model where your database never leaves your network.
Every team has the same bottleneck. The data is in PostgreSQL, Snowflake, or BigQuery. The questions are in English. And the person who can bridge the two is either a data analyst with a two-week backlog or an LLM that hallucinates column names. WrenAI is an open-source GenBI (Generative Business Intelligence) agent built to close that gap — you ask in natural language, it returns accurate SQL, charts, and BI insights.
What puts it on this blog: it's self-hostable, it supports Ollama for fully local inference, and your database never has to leave your network. You can run the whole stack on your own hardware.
This is a deep look at what WrenAI is, why the semantic layer (MDL) matters, the architecture, the self-host path, what it costs, where your data goes, and what it honestly can't do. If you've ever wanted "my own GPT-for-SQL" that doesn't ship your schema to a vendor, read this.
1. The "Talk to Your Data" Promise
The pitch is seductive and usually half-true. Point an LLM at your raw schema and ask "what were last quarter's top customers?" and it will confidently produce SQL that joins the wrong tables or invents a column. The problem isn't the model — it's that business meaning isn't in the schema. "Active user" means something specific to your company, and a raw users table doesn't encode it.
WrenAI's entire design is built around that gap. It doesn't just prompt a model with your DDL. It builds a context layer that carries business meaning, then retrieves the right slice of that context for each question.
2. What WrenAI Is
WrenAI is an open-source GenBI AI agent that empowers data, product, and business teams to chat with their data and generate Text-to-SQL, charts, spreadsheets, reports, and BI. It's built by Canner and ships under an open-core model: the core (MDL semantic contract, Rust semantic engine, wren CLI, GenBI apps, framework SDKs, wren-core-wasm) is open.
Supported LLM models include OpenAI, Azure OpenAI, Google Gemini, Vertex AI, Bedrock, Anthropic, Groq, DeepSeek, Ollama, and Databricks. Crucially, Ollama means you can run the SQL-generation model fully on your own hardware — no data leaves your network except to your local model.
3. Architecture: Three Parts and a Core
Wren AI OSS includes:
- Wren UI — connect data, define relationships, ask questions
- Wren AI Service — retrieval, prompting, SQL generation, validation
- Wren AI Core (formerly Wren Engine) — the business-context and modeling layer
- wren-core is a Rust semantic engine powered by Apache DataFusion. It plans and executes modeled SQL across supported sources.
- qdrant is the vector database for embeddings (the retrieval side).
- ibis-server handles data processing.
- wren-core-wasm compiles the semantic engine to WebAssembly, so MDL-aware SQL and GenBI dashboards can run in the browser.
docker compose up --build -d
open http://localhost:3000
4. The Semantic Layer (MDL): Why It Matters
This is the part that separates WrenAI from "LLM + schema prompt." MDL (Modeling Definition Language) is the semantic contract: it defines models, relationships, calculated fields, views, and agent-oriented metadata in files you can read, review, version, and fork.
Asking an LLM to query raw schemas breaks down when business meaning isn't explicit. WrenAI improves that across four problem areas:
1. Context collection — combine metadata, schema, relationships, business logic
2. Retrieval — find the right context for each question
3. SQL generation — produce executable SQL across engines, grounded in the model
4. Collaboration — capture feedback, reuse, access control
A "customer" isn't just select from users. With MDL, "active customer" can be a defined calculated field with the exact rule your business uses. The model generates SQL against that meaning, not against a guess.
5. Installation: Self-Host in Minutes
git clone https://github.com/Canner/WrenAI.git
cd WrenAI
docker compose up --build -d
open http://localhost:3000
Configure your LLM in config.yaml:
language: English
llm:
provider: ollama
model: qwen2.5:14b
base_url: http://localhost:11434
Restart the AI service:
docker compose up -d --force-recreate wren-ai-service
For detailed provider examples (OpenAI, Gemini, Bedrock, etc.), WrenAI ships configuration docs per provider.
6. Data Sources: 12+ and Growing
WrenAI supports a broad set of engines:
- PostgreSQL, MySQL, Microsoft SQL Server, Oracle
- BigQuery, Snowflake, Redshift, Databricks
- DuckDB, ClickHouse, Trino, Athena
- Apache Spark (and more via community votes)
7. Hands-On: From Question to SQL
1. Connect your data source (e.g., a local Postgres or DuckDB).
2. Define relationships in the UI — link orders to customers, mark keys.
3. Add business definitions in MDL — "active customer = logged in within 30 days."
4. Ask: "What were last quarter's top 5 customers by revenue?"
5. WrenAI retrieves the relevant context, generates SQL grounded in your MDL, and shows you the query
6. One click → chart, or export to spreadsheet/report.
You see the SQL. You can edit it. The model isn't a black box; the semantic layer is inspectable and version-controlled.
8. GenBI Insights and Charts
Beyond SQL, WrenAI produces AI-generated summaries alongside queries, turning raw results into actionable visuals. The GenBI feature converts query results into reports and charts. In the newer open-core, GenBI apps are agent-built, browser-side dashboards powered by wren-core-wasm, deployable to Vercel or Cloudflare Pages.
WrenAI also answers exploratory questions — "What data do I even have?" — which is genuinely useful when onboarding onto an unfamiliar warehouse.
9. Agent-Native and MCP
WrenAI exposes an MCP server via wren-engine, so agent workflows can call it. The framework SDKs (LangChain, Pydantic AI) let you attach a Wren project to agent frameworks. Skills like generate-mdl, onboarding, enrich-context, and genbi run on demand from the wren CLI, so AI coding agents can operate WrenAI safely and reproducibly.
This is the forward edge: not just a chat UI, but a component other agents can use to query governed data.
10. Honest Limitations
WrenAI is honest about its ceilings:
- SQL quality depends heavily on the LLM. The docs explicitly recommend the most powerful model available; weak models produce weaker, slower, or inaccurate SQL. With Ollama, a 14B-class local model is fine for simple schemas but will struggle on gnarly multi-join questions.
- Semantic layer setup is real work. MDL is what makes it accurate, and defining it takes effort — especially for messy legacy warehouses. The payoff is accuracy; the cost is upfront modeling.
- Classic is sunset. The earlier Docker-based chat-first product (Wren GenBI Classic) is on a legacy branch and gets no security fixes. Use the actively maintained open-core.
- Not a full BI replacement. It's excellent for ad-hoc, governed questioning; it's not Tableau for pixel-perfect dashboards (though GenBI apps are closing that gap).
- Retrieval can miss. If your MDL is thin, retrieval returns the wrong context and the SQL drifts.
11. What It Costs
WrenAI is open-core and free to self-host. Your costs:
- Your LLM bill — cloud models (OpenAI/Gemini/etc.) per token.
- $0 for inference if you run Ollama locally — but you pay in GPU/RAM and electricity.
- Your infra — Docker host, Postgres/Redis/Qdrant. A small VPS or a workstation handles it.
- Your time — modeling the MDL, the part that buys accuracy.
12. Where Your Data Goes
This is the privacy core. Your data stays in your database. WrenAI connects to it; the model (if Ollama) runs on your machine. The only thing that leaves your network is what you explicitly route to a cloud LLM — and if you pick Ollama, nothing leaves at all.
Even with a cloud model, WrenAI's retrieval sends
context (schema + MDL + relevant rows), not your entire warehouse, to the model. That's a narrower exposure than "ship the whole DB to a vendor BI cloud." For the strictest setups, Ollama + local DuckDB = fully air-gapped GenBI.13. Troubleshooting
- SQL is wrong? Your MDL is too thin. Add relationships and calculated fields; the model grounds on those.
- Port 3000 busy? Change
HOST_PORTin.env. - Service won't start? Docker needs 8GB+ RAM recommended; check
docker compose logs [service]. - Local model weak? Bump the Ollama model size (e.g., 14B → 32B) if you have VRAM; or use a cloud model for hard queries.
- Classic vs core confusion? Use the maintained open-core; the legacy/v1 branch is sunset and unmaintained.
14. Who Should Use It
Use WrenAI if: you're a data/product/business team that wants governed, plain-English database access; you need self-hosted BI without shipping schemas to a vendor; or you want a component other agents can query. It's especially strong paired with Ollama for fully private GenBI.
Skip it if: you need pixel-perfect executive dashboards (use a dedicated BI tool), or you can't invest in modeling the semantic layer (a raw "LLM + schema" approach will disappoint).
15. FAQ
Is WrenAI open source? The core is open (MDL, Rust engine, CLI, wren-core-wasm, SDKs). A hosted commercial tier also exists.
Can it run fully locally? Yes — Ollama for the model + a local DuckDB/Postgres for data = no data leaves your network.
Which databases? 12+, including PostgreSQL, MySQL, BigQuery, Snowflake, DuckDB, ClickHouse, Trino, SQL Server, Databricks, Redshift, Oracle, Athena, Spark.
Why not just prompt an LLM with my schema? Because business meaning isn't in the schema. MDL encodes it; retrieval grounds the SQL. Accuracy is the whole point.
How is it different from Open WebUI? Open WebUI is a chat frontend for models. WrenAI is a BI agent with a semantic layer for databases. Different job — see the Open WebUI deep-dive for the chat side.
16. Building the MDL: A Concrete Example
The semantic layer is where accuracy is won or lost. Here's a small but real MDL snippet for a SaaS schema:
models:
- name: customers
columns:
- name: id
- name: created_at
- name: last_login_at
- name: orders
columns:
- name: id
- name: customer_id
- name: amount
- name: created_at
relationships:
- name: orders_customer
from: orders.customer_id
to: customers.id
calculated_fields:
- name: active_customer
model: customers
formula: "last_login_at >= now() - interval '30 days'"
views:
- name: monthly_revenue
model: orders
measures:
- name: total
aggregation: sum
column: amount
dimensions:
- name: month
column: created_at
grain: month
Now "top customers by revenue last quarter" resolves to a clean join on orders.customer_id → customers.id, grouped by quarter, filtered to created_at in range. "Active customers" uses the defined 30-day rule — not the model's guess. The MDL is the difference between "plausible SQL" and "correct SQL," and it's reviewable and version-controlled like code.
17. WrenAI vs Naive Text-to-SQL
A naive approach: dump the DDL into a prompt and ask for SQL. Failure modes:
- Invented columns — the model guesses a
revenuecolumn that doesn't exist. - Wrong joins — links
orders.user_idwhen it'scustomer_id. - No business logic — "active" becomes
status = 'active'when your rule is time-based. - No validation — the SQL runs and errors, or worse, runs and lies.
18. Privacy Deep-Dive: What Actually Leaves Your Network
People hear "AI queries my database" and assume the whole warehouse ships to a model. With WrenAI + Ollama, here's the real data flow:
1. Your database stays put. WrenAI connects to it from your host.
2. The model (Ollama, local) receives only the
3. The generated SQL runs against your database from your host.
4. Results return to your host and render in the UI.
If you instead point WrenAI at a cloud LLM, step 2 sends that retrieved context to the provider. That's narrower than "ship the warehouse to a vendor BI cloud," but it's still exposure — so for the strictest setups (HR, finance), use Ollama and keep the model local. The architecture makes "fully private GenBI" a configuration choice, not a rewrite.
19. Running WrenAI in Production
For a real deployment:
- Model choice is the lever. Use the strongest model you can for the SQL step; weak models produce weak SQL. A 14B local model is fine for simple schemas; for gnarly multi-join questions, use a cloud model or a 32B+ local one.
- Put it behind auth. The Docker stack exposes
:3000; put it behind a reverse proxy with SSO if multiple analysts use it. - Size the host. Postgres/Redis/Qdrant + the AI service want 8 GB+ RAM. A small VPS or a workstation handles a team.
- Version the MDL. Treat
modeling_definition.yaml(or the MDL files) like code — review changes, because a bad definition silently degrades every query. - Cache embeddings. Qdrant holds context embeddings; size it for your schema breadth.
20. Limitations, Honestly
The line between "magic" and "disappointing" is the MDL:
- No MDL, no accuracy. Point WrenAI at a raw schema with no definitions and you get plausible-but-wrong SQL — the exact failure it exists to prevent. The fix is modeling, which is work.
- Model-bound. SQL quality tracks your LLM. A free local 7B will frustrate you on anything complex.
- Not pixel-perfect BI. It's excellent for governed ad-hoc questions; it's not Tableau for board decks (GenBI apps are closing this, but slowly).
- Classic is sunset. Use the maintained open-core; the legacy chat product is unmaintained.
- Retrieval can miss. Thin MDL → wrong context retrieved → drift. You must curate.
22. A Guided MDL Session
Let's model a tiny business — a coffee subscription — interactively:
1. Connect orders (id, customer_id, amount, created_at) and customers (id, email, city, signup_date).
2. Define relationship: orders.customer_id → customers.id. Now "revenue per customer" joins correctly.
3. Add a calculated field: ltv = sum(amount) grouped by customer_id. "What's my top customer's LTV?" now resolves.
4. Add a view: monthly_recurring = sum(amount) where created_at in last 30 days, by city.
5. Ask: "Which city has the highest LTV?" → WrenAI retrieves the ltv definition and the relationship, generates SQL against them, returns the answer with the query shown.
Without the MDL, "LTV" is undefined and the model guesses a column. With it, the question is grounded in
your definition. The session takes ten minutes once; every later question benefits. That's the semantic layer paying off.23. WrenAI vs Traditional BI Tools
Where does WrenAI sit versus Metabase or Looker?
- Metabase/Looker: you (or an analyst) write the query or define the model; business users click dashboards. Great for known questions; poor for "ask something nobody charted."
- WrenAI: you ask in English; it generates the SQL from the semantic layer. Great for ad-hoc, governed exploration; less polished for pixel-perfect executive dashboards (today).
25. WrenAI for Non-Technical Analysts
The pitch isn't only for engineers. A business analyst who can't write SQL can:
1. Open the Wren UI, connect the warehouse (IT does this once).
2. Ask "which product line grew fastest last quarter?" in plain English.
3. Read the answer — and the SQL underneath, shown for trust.
4. Click "chart" to visualize, or "export" to a spreadsheet.
The SQL is visible, not hidden. That matters: an analyst can learn SQL by reading what WrenAI generated, and can correct it. The semantic layer means the questions map to
business* definitions, not raw columns — so "active customer" is the company's rule, not a guess.For a non-technical user, the win is speed (no ticket to the data team) and safety (queries run on the governed semantic layer, not free-form raw SQL that might hit the wrong table). The cost is the initial MDL modeling, which IT or a power user does once.
26. Data Source Deep-Dive: Connecting Postgres
A concrete connect:
# config.yaml (Postgres)
data_source:
type: postgres
host: db.internal
port: 5432
database: analytics
user: wrenai_ro
password: ${PG_PASS}
Use a read-only role (wrenai_ro) — WrenAI only needs to read. Then in the UI, define relationships and calculated fields. The Rust engine (DataFusion) plans and executes the modeled SQL against Postgres. Your data stays in Postgres; only the retrieved context and results move to the model (or stay local with Ollama).
This read-only pattern is the security baseline: even if the model is prompted to do something destructive, the DB role can't write. Pair it with Ollama for fully air-gapped GenBI.
28. WrenAI and the Local-First Thesis
This blog's thesis is "AI you can run on your own machine." WrenAI is the BI pillar of that thesis. Pair it with Ollama and you get fully private GenBI: your database stays put, the model runs on your hardware, and the only thing that moves is the retrieved context for each question.
That combination — Ollama (inference) + WrenAI (semantic layer) — is the self-hosted answer to a cloud BI vendor that would otherwise hold your schema, your queries, and your answers. For a data-sensitive team, it's the difference between "we can analyze our data" and "we can analyze our data without shipping it out."
The MDL is the glue: it's a local, version-controlled file that encodes your business meaning. No vendor lock-in, no black box. That's why WrenAI belongs in this series alongside Ollama, Open WebUI, and the rest.
29. Common WrenAI Mistakes
- Skipping the MDL. Pointing WrenAI at a raw schema and expecting magic. You get wrong SQL. Model the layer; it's the job.
- Weak model for hard schemas. A 7B local model on a 200-table warehouse will frustrate you. Use a strong model for the SQL step.
- No auth in front. Exposing
:3000to the internet. Put it behind a reverse proxy with SSO for multi-user. - Trusting retrieved context blindly. Thin MDL → wrong context → drift. Curate the MDL.
- Using the sunset classic. The legacy chat product is unmaintained. Use the open-core.
30. Verdict
WrenAI is the most credible "talk to your data" tool that doesn't force your schema into someone else's cloud. The semantic layer is the right idea, the Rust/DataFusion engine is serious, and Ollama support makes a fully-private GenBI deployment real. The cost is modeling effort up front — but that effort is exactly what turns hallucinated SQL into answers you can trust.
Related:
Comments (0)
No comments yet. Be the first to comment!