What should you build customer-facing AI analytics on?
Build all of it, dashboards and AI chat alike, on one data model served from a server you control. The model holds the definitions and the tenant rule, and the server applies both to every query, whether it comes from a dashboard, your chat or a customer's agent. If the dashboards come from one place and the chat from another, a customer sees two different numbers for the same thing. With one model, a new surface gets the same answers and the same isolation with no new access code.
The three common options, and what each costs:
- An LLM writing SQL against your tables. Fastest to demo. A prompt or skill that explains your tables can make it work well on the questions you expect. It doesn't carry over to questions you didn't expect, and nothing checks the queries it writes, so its answers can differ from your dashboards. Every query also has to carry the tenant filter, unless the database enforces it with row-level security. One missed filter shows a customer someone else's rows. Building it yourself compares this option in full.
- An embedded BI tool with an AI feature. Quick to ship dashboards and chat. The model and the access rules live inside that product, so your own agent or API has to reach the data through it.
- A data model served to your app. One set of definitions and one tenant rule for every surface, over an API or MCP. The cost is writing the model and running the server, or paying someone to run it.
The questions worth asking any vendor:
- Is the tenant rule enforced on the server for every query, including the chat's?
- Can the customer, or your application, change which tenant it is?
- What does a refused or empty query return?
- Does the chat's value search respect tenant boundaries?
Why is tenant isolation harder with an AI chat than with dashboards?
A dashboard runs queries someone built and checked in advance. A chat writes new queries from whatever the customer types, including questions nobody planned for. So the isolation can't depend on which questions get asked, or on what the prompt says. It has to hold for every query the chat can write.
Two failure modes are easy to miss:
- A refusal can read as zero. If a caller who should be refused gets an empty result instead of an error,
count()returns 0, and the chat can report that as a real number. Refuse with an error, and show the customer that this data isn't available to them. - Value search can leak values. A chat matches what the customer typed against an index of field values. One index serves every caller, so on a source with access rules, one customer's values can show up for another. Keep value search off on those sources.
What does curation control in a multi-tenant analytics app?
Curation controls what exists to query at all, and it is the same for every customer. It decides which sources are available and which fields each source exposes, so raw tables, staging joins and internal columns stay out of every customer's reach. It works at two levels, as the exports and field visibility docs describe:
- Sources. The package's
index.malloyis the menu: it exports the sources callers may query. A query on any other source gets a 404. - Fields.
public,internalandprivatedecide which fields each source exposes. Onlyprivateprotects a field. A query can re-expose aninternalfield by extending the source.
Because the menu lists what can be queried, a table someone adds next quarter isn't reachable by accident. Curation can't vary by customer, so keeping each customer to their own rows is authorization's job.
How does authorization keep each customer to their own rows?
Authorization keeps each customer to their own rows with a rule on the server that depends on who is asking. The rule reads the caller's tenants, filters every query on a source to those tenants, and refuses callers who may not query the source at all. Two annotations on a source do it, per the access control docs:
##! experimental.givens
given:
#(secure)
TENANTS :: string[]
#(access_filter) tenant in $TENANTS
source: support_performance is ticket_core include { ... }#(access_filter)filters every query on the source to the caller's tenants.#(authorize)decides whether a caller may query the source at all. A refused caller gets a 403, not an empty result.- A given is a named value the model receives when a query runs, written with
$, as in$TENANTS. A secure given is one the customer can't set: it is filled in from the customer's verified sign-in. A rule on an ordinary given is only a filter, because whoever sends the query can send any value.
An access rule is checked on the source a query starts from, never through a join, so put the rules on the sources the menu exports.
How does your application tell the analytics server which tenant is asking?
Your backend tells it, from the customer's verified sign-in, never from anything the browser sends. The customer's browser talks only to your backend. Your backend calls the analytics server for that customer's tenant, and the access rule in the model filters the rows. Your application never writes the tenant filter itself.
Malloy Publisher doesn't sign anyone in. It runs behind your gateway or backend, which authenticates the customer, sets secure givens such as TENANTS from that sign-in, and is the only way to reach Publisher, as Publisher's row-level access docs describe. A bug in your backend can still pick the wrong tenant, but no query through the model can remove the filter.
How do you embed tenant-scoped AI analytics in your product?
Keep credentials on your server, never in the browser, and let the analytics server scope every query. Then either call the analytics server from your own chat or UI, or put a data app inside your page. Both options use the same tenant rule.
Your own chat or UI. When a customer signs in, your backend calls the analytics server for that customer's tenant, over MCP or the REST API, and gets back rows already scoped to that tenant.
A data app inside your page. A data app is an HTML page shipped in the package, and its queries run under the same access rules. Publisher.embed puts it in your page as an iframe, with a short-lived token your server mints for each embed (embedding docs). The token travels in the URL, so never pass a long-lived or admin token.
What does customer-facing AI analytics look like in production?
In production, customer-facing AI analytics answers from definitions the business already agreed on, and says so when the data can't answer a question. VideoAmp, which puts AI answers in front of its clients, wrote the rules for combining its metrics into a data model and tested the AI before launch.
Given 20 analyst questions with no answer key, the agent surfaced all 35 of the dimensions and measures the correct answers depend on. Asked for data the report doesn't carry, it said so and named the gap instead of making up a number.
How should a team start building tenant-scoped AI analytics?
Start with the open-source pieces, then decide who runs the sign-in. Malloy is MIT-licensed, and Malloy Publisher enforces #(authorize) and #(access_filter) and refuses to load a model whose access rules are malformed. In the post Policy is prose, compliance is controls, Publisher refused to load a model after the given behind a row filter lost its #(secure) annotation. If you run Publisher yourself, you bring the sign-in and the gateway in front of it.
Credible runs Publisher as a managed service and works out who is asking. Each tenant gets a group and an API key, Credible fills the built-in $GROUPS given from the key, and a rule such as #(access_filter) tenant_id in $GROUPS scopes every query, so your backend only picks the key (tenant isolation docs). On Credible, the exports change only when you publish a new version, and every request is logged with the caller's identity. Access rules and audit logs are available in Credible today; see pricing.
Frequently asked questions
Is it safe to put an AI chat on customer data?
Yes, if the tenant rule is enforced below the chat. A customer can type anything, so the prompt can't be what keeps tenants apart. Every query the chat writes has to pass the same server-side tenant rule as any other query, and a refused query has to reach the customer as an error, not as zero.
How do embedded analytics keep each customer's data separate?
With a rule enforced on the server, keyed to an identity the customer can't change. The application tells the server which tenant is asking, through a key or a signed identity, and the server filters every query to that tenant's rows before it runs. The filter shouldn't live in application code, where one bug can widen what a customer sees.
How do I embed AI analytics in my SaaS app?
Keep the credentials on your server. For your own UI, your backend calls the analytics server for the signed-in customer's tenant. To embed an analytics page from another domain, your server mints a short-lived token for each embed, and the analytics server has to allow framing from your domain. Never put a long-lived key in the browser.
What is the difference between curation and authorization?
Curation decides what exists to query, and it's the same for every caller: which sources are available and which fields each one exposes. Authorization depends on who is asking: whether this caller may query a source at all, and which rows they see. A multi-tenant product needs both, one to hide internal tables and one to separate customers.