Why the semantic layer (dbt Semantic Layer, Looker LookML, Cube) is the right abstraction for LLM warehouse access -- and how to wire it up.
The semantic layer was designed for BI tools -- Looker's LookML, dbt's Semantic Layer, Cube's data model -- but it is the right interface for LLMs too. It provides three things that raw SQL access cannot: consistent metric definitions (revenue means the same thing everywhere, not five different JOIN variations), governed access (the LLM can only query what the semantic layer exposes), and pre-validated logic (the business rules are encoded once, not re-derived by the LLM every time).
The alternative to a semantic layer is giving LLMs access to raw warehouse tables. This works at small scale and fails at large scale in predictable ways: the LLM calculates revenue differently on different queries, it queries tables that should be off-limits, and it invents JOIN logic that produces plausible-looking but wrong results. Every one of these failures is a data governance problem. The semantic layer is the data governance solution.
Wiring a semantic layer to an LLM agent is an infrastructure problem data engineers own end to end. You need to expose the semantic layer's API as a tool the agent can call, populate the agent's context with metric and dimension descriptions accurate enough to select the right ones, and validate returned results against known sanity checks before surfacing them to users. The LLM decides what to ask; the semantic layer decides what is allowed; the data engineer builds the pipe between them.
The clearest articulation of why the semantic layer -- not raw SQL access -- is the right interface between LLMs and the warehouse. The argument about consistent metric definitions is the one to internalize.
The reference for setting up MetricFlow and exposing metrics through the dbt Semantic Layer. If your organization already uses dbt, this is the lowest-friction path to giving LLMs safe, governed warehouse access.
Cube is a strong alternative if you are not in the dbt ecosystem. Its API-first design and pre-aggregations make it well-suited for serving both BI tools and LLM agents from the same semantic model.
Some course links above are affiliate links. If you enroll, we may earn a small commission at no extra cost to you.
New resources and perspective on building AI-ready data systems, a few times a month. No spam.