Wren AI
Turn any AI Agents into world-class data analysts through the open context layer that gives AI agents grounded, governed memory, context, and SQL across 20+ data sources, that helps you build GenBI, dashboards, and agentic analytics.
Wren AI is the open context layer for AI agents. It sits between your data sources and any agent or application that needs to query them.
The goal is simple: one governed context layer for every data consumer. Humans and agents should not rebuild business logic from scratch, argue over which number is right, or bypass governance just because the interface changed.
Wren AI gives them the same machine-readable understanding of your business data: what the data means, how it should be joined, which definitions are approved, and how queries should be planned against the underlying database.
Why Wren AI exists
Your agent reads schema, but schema does not tell it:
status = 4means refundedloyalty_v3is the table your team actually uses- "monthly active users" excludes service accounts
- "Project Lighthouse" maps to
campaign_id = 4172in a planning doc nobody linked to the warehouse

Without that meaning, the agent writes confident, plausible, wrong SQL. The demo looks fine. The pilot looks fine. Production is where it breaks.
Business context cannot be locked inside someone else's product. Your business definitions outlive your tools, and they deserve a format your team can inspect, version, fork, and share.
What Wren AI provides
Wren AI turns raw database structure into a reusable context layer. It helps agents move from "I can see tables" to "I know what this business means by revenue, customer, refund, churn, and active account."
For real business questions on real company data, an agent needs five layers of context (see What does Wren AI mean by context? for the full breakdown):
| Layer | What it gives the agent | Status |
|---|---|---|
| Structural | Tables, columns, types, keys, and relationships | Ships today |
| Semantic | Business-facing models, reusable calculations, canonical tables, enum meaning | Ships today |
| Business | Company definitions such as active customer, revenue, churn, and internal naming | Ships today |
| Operational | Approved join paths, sanctioned queries, governance rules, and things never to compute | In active development |
| Behavioral | Memory of past questions, successful SQL, user feedback, and examples | In active development |

Here is what that looks like in practice. You write a small MDL file describing what your data means, and Wren AI plans every modeled query through it. See What does MDL do for the agent? for the deeper view.
# models/customers/metadata.yml
name: customers
table_reference:
catalog: jaffle_shop
schema: main
table: customers
primary_key: customer_id
columns:
- { name: customer_id, type: INTEGER, is_primary_key: true }
- { name: first_name, type: VARCHAR }
- { name: number_of_orders, type: BIGINT }
- { name: customer_lifetime_value, type: DOUBLE }
The agent (or you, or any SDK) now queries customers as if it were a regular table:
$ wren --sql "SELECT first_name, customer_lifetime_value FROM customers ORDER BY 2 DESC LIMIT 3"
first_name customer_lifetime_value
Tiffany 1245.67
Lukas 1102.30
Jennifer 1086.45
Behind the scenes, Wren AI:
- Looks up
customersin the MDL - Resolves it to the physical table declared in
table_reference - Drops columns not declared in the model (e.g.
email,phone), keeping them invisible to the agent - Applies any rules from
instructions.md(default filters, canonical tables, business definitions) - Returns rows
What is in the open core
The open core includes:
- MDL (Modeling Definition Language) — the semantic contract. MDL defines models, relationships, calculated fields, views, and agent-oriented metadata in files you can read, review, version, and fork.
- Rust semantic engine — powered by Apache DataFusion. It plans and executes modeled SQL across supported data sources such as PostgreSQL, MySQL, BigQuery, Snowflake, DuckDB, ClickHouse, Trino, SQL Server, Databricks, Redshift, Oracle, Athena, Apache Spark, and more.
wrenCLI — commands for querying, planning, validating, building context, profiling data, and managing memory.- Skills — structured workflows such as
wren-generate-mdlandwren-onboardingthat let AI coding agents operate Wren AI safely and reproducibly. - Framework SDKs — LangChain and Pydantic AI integrations for attaching a Wren project to agent frameworks.
- wren-core-wasm — the semantic engine compiled to WebAssembly, so MDL-aware SQL can run in the browser.
Roadmap
The active arcs are end-to-end context enrichment, a correctness loop (including small golden evals agents can run), and tighter agent SDK coverage. See GitHub Discussions for live design threads and the prioritized roadmap.
Start here
- Install
- Quickstart with
jaffle_shopsample data - Connect your own database
- Concepts — the design ideas
- Model your business — turn schema into MDL
Looking for the GenBI app docs?
The Wren AI GenBI app, the Docker-based chat-first BI product, is now sunset. Its code lives on the legacy/v1 branch and no security fixes will be issued. Existing deployments still work; reference docs are kept under Wren AI GenBI — Sunset in the sidebar.
For an actively maintained version with the same feature set, see Wren AI Commercial.
Dig deeper
Each Concept page answers one design question: