Multi-Tenant Architecture When Your SaaS Uses AI
The tenant isolation choices you make on day one either save you or haunt you two years later. This is the version we wish more teams got right the first time.
Multi-tenancy in a traditional SaaS is a database problem. Multi-tenancy in an AI SaaS is a database problem, a retrieval problem, a cost-attribution problem, and a compliance problem — often at the same time. The choices you make in the first month determine whether year two is calm or chaotic.
At Augere Labs we've built and audited enough of these that the decision tree is pretty clear. This post walks through the patterns that hold up and the ones that don't.
What "tenant" even means in an AI SaaS
Before architecture, decide the shape. A tenant might be:
- A single customer's workspace (most common in B2B SaaS).
- An end user (in consumer AI products).
- A brand or business unit inside a larger customer (enterprise).
- A project or channel within a workspace (agencies, dev tools).
Get this wrong on day one and every access rule becomes a special case. In projects like these, spending a week on the tenant model saves months later.
Three isolation models, and where each fits
Shared everything (row-level isolation)
One database, one schema, one set of tables. Every row has a workspace_id and RLS or app-level filters enforce isolation. This is the right default for 90% of AI SaaS products.
It's cheap to operate, easy to migrate, and Postgres with row-level security makes leaks structurally hard. See our Postgres for AI SaaS post for the database side of this argument.
Schema-per-tenant
Each customer gets their own schema in a shared database. Middle ground — better isolation, but migrations become painful past a hundred tenants. Useful when regulatory pressure exists but a full separate database is overkill.
Database-per-tenant
Each customer, their own database. The right answer for highly regulated industries (health, finance, government) and enterprise deals that require it in the contract. Painful in every other case — deployments, backups, migrations all multiply.
Start on shared everything. Move only when a specific customer or regulation forces the change, and price the move accordingly.
The AI-specific dimensions
Embeddings and vector search
Your vector table is a tenant boundary too, and it's the one teams forget. Every embedding row must carry the tenant ID, and every similarity search must filter by it. Missing this filter is how one tenant's docs surface in another tenant's answers — a class of bug you cannot recover from without a hard reset.
With pgvector, add workspace_id to your embeddings table and index it. Every ANN query includes a WHERE workspace_id = ?. RLS covers you if configured; do not rely on the application layer alone.
Fine-tuning and per-tenant models
Some teams fine-tune per-tenant models. This looks appealing and usually isn't. Storage, retraining, and versioning explode. RAG with per-tenant retrieval scoping is almost always the right answer instead. Only fine-tune per tenant if a customer has data you cannot expose at query time — an extreme edge case.
Cost attribution
Every LLM call must be tagged with the tenant it belongs to. This is not optional in a real business — without it, you cannot answer "which customers are unprofitable" and cannot bill fairly. Log tenant_id, model, input tokens, output tokens, and cost estimate on every call.
Prompt customization
Sometimes tenants want brand-specific tone, glossaries, or guardrails. Model this as tenant-scoped configuration layered on top of a shared system prompt — not by forking the prompt per tenant. Forked prompts turn into a maintenance disaster within a quarter.
Row-level security as the backbone
Postgres RLS lets you tie access rules to the authenticated user. Every table has policies like "only rows where workspace_id matches the caller's active workspace are visible." Combined with Supabase or Neon Auth, this pushes isolation down to the database.
The advantage is structural: even if your app has a bug and forgets to filter, the database refuses. This one property removes an entire category of "the wrong tenant saw the wrong data" bugs. It's the single most impactful architectural decision for a multi-tenant AI SaaS.
Mistakes teams make
Enforcing tenant isolation only in the app
App-layer filters break. Some junior developer writes a query that forgets the where clause. Ten minutes later a customer has seen another customer's data. Database-enforced isolation prevents this by construction.
Using a shared vector index without filtering
"We'll just filter results after retrieval." That's not how similarity search works — you retrieve based on vector distance first, then post-filter. If you have 10,000 chunks and retrieve top 10 without tenant scoping, you'll frequently return zero matching results after filtering. Filter at query time, at the index level.
Global caches on user-visible AI outputs
Caching a "how do I upgrade my plan?" answer across tenants sounds efficient. Then Tenant A gets Tenant B's brand voice, or worse, their pricing. Tenant-scope every cache key, always.
Ignoring cost attribution until it's expensive
Backfilling cost attribution across a year of logs is nearly impossible. Instrument on day one, before it looks necessary.
Real example
An AI writing tool we advised had a shared embeddings index and clever app-layer filtering. It worked fine at fifty customers. At two hundred, a small refactor removed a filter, and two enterprise customers briefly saw content from other tenants surface in "similar past writing" suggestions. Full incident: three days of investigation, one hard customer conversation, and a rebuild of the retrieval layer with pgvector plus RLS.
The rebuild took two weeks. The trust rebuild took two quarters. This is the kind of thing that should be designed in on day one and never becomes urgent — but only if you get it right early.
What good looks like
- Postgres with RLS policies on every tenant-scoped table.
- Embeddings table with
tenant_idcolumn and RLS enforcement. - Every LLM call tagged with
tenant_id, model, tokens, cost. - Configuration per tenant (glossaries, tone, guardrails) layered on shared prompts.
- Feature flags scoped to tenants, not to global environments.
- Cache keys always include the tenant ID.
Trade-offs
RLS adds a small overhead on queries. It's usually negligible; when it isn't, the fix is better indexes, not disabling RLS. Anyone recommending you turn off RLS for performance is optimizing the wrong end.
Per-tenant configuration adds complexity. But not adding it means you'll eventually have a config table with fields like customer_92_disable_summary_style, which is worse.
Common misconceptions
"Multi-tenant is a database concern only." It's a database, retrieval, prompt, cache, and cost concern. Every layer needs the tenant boundary.
"We'll separate customers later if we need to." Migrating from shared to isolated is painful. Design as shared with hard boundaries, and lift only specific customers when regulation demands it.
"Fine-tuning per tenant solves the customization problem." Almost never worth it in 2026. RAG with tenant-scoped retrieval is cleaner, cheaper, and works.
Frequently Asked Questions
Is shared-schema multi-tenancy secure enough for enterprise customers?
Yes, with RLS and proper audit logging, it's secure enough for most enterprises. Some regulated industries (health, finance) will still require dedicated infrastructure — expect that in contracts.
How do I handle a customer who wants their own database?
Price it as a premium tier. Deploy a separate Postgres instance for them and route their traffic. Keep the codebase single — one code path, two databases.
Should embeddings live in the same database as my app data?
Yes for most SaaS. pgvector in the same Postgres removes an entire category of sync bugs. Break it out only when scale demands it.
How do I audit that isolation is actually working?
Run periodic queries as different tenants and verify you cannot see each other's data. Automate this as a test that runs weekly.
Where to go next
Pair this with Postgres vs MongoDB for AI SaaS and choosing a vector database. For the auth layer, see Clerk vs Auth0 vs Supabase Auth.
Working with us
Getting multi-tenancy right early is the highest-leverage architecture decision in an AI SaaS. We help teams design this on day one so year two is calm — happy to review your current model.
FAQ
Frequently asked questions
What's the safest multi-tenant model for an AI SaaS?+
Shared database with row-level security in Postgres. It's structurally safe, cheap to operate, and scales further than most SaaS products ever need.
Should I use one vector index for all tenants?+
Yes, with a tenant column and filtering at query time. Separate indexes per tenant scale badly and don't add real security if RLS is set up correctly.
Do I need per-tenant fine-tuned models?+
Rarely. RAG with tenant-scoped retrieval and per-tenant configuration handles almost every customization need without the fine-tuning overhead.
How do I attribute AI costs to specific customers?+
Tag every LLM call with the tenant ID, model, and token counts at log time. You cannot backfill this reliably later.
Building something similar?
Let's talk in 30 minutes.

