← Insights
automate

Production AI Architecture for B2B SaaS

Adding AI features to a real B2B product that must hit the same reliability bar as everything else. Reference architecture, SLAs, and tenant isolation

Your B2B product has a 99.9 percent uptime SLA, SOC 2 controls, strict tenant data isolation, and a support team that gets paged when latency crosses a threshold. Then you add an AI feature, and somehow everyone agrees to grade it on a curve. It calls an external model that has its own outages. It's nondeterministic. It leaks one tenant's data into another's results if you're careless. It costs real money per request. And it gets shipped with none of the reliability scaffolding the rest of the product is required to have.

That curve is a mistake. Your enterprise customers don't care that a feature is "AI." They bought a product with an SLA, and the AI feature is part of the product. It has to meet the same bar: the same uptime, the same isolation, the same observability, the same graceful behavior when a dependency fails. The interesting part is that AI features have failure modes the rest of your stack doesn't, so meeting the bar takes architecture the rest of your stack didn't need.

The reference architecture

A production AI feature in a B2B product is not a direct call from your app to a model API. That's the prototype. The production shape is a layered architecture with a dedicated service between your app and any model.

An AI gateway service. All AI calls route through one internal service, not scattered across your codebase. This is where you centralize the things that have to be consistent: provider routing, retries, timeouts, rate limiting, caching, cost tracking, prompt versioning, and logging. Scatter model calls across twelve endpoints and you've lost control of all of them; route them through one service and you can change models, add a fallback, or cap spend in one place.

A retrieval layer, where the feature is grounded in your data — the vector store and hybrid retrieval that keep answers tied to real content instead of model memory. Multi-tenant, which is its own problem, below.

A validation and guardrail layer between model output and the user — checking outputs against rules, enforcing scope, catching the confident-wrong cases before they reach a customer.

An observability layer wrapping all of it, because an AI feature you can't see is an AI feature you can't operate.

The principle: the model is a dependency, like your payments provider or your email service. You wrap dependencies in a service you control, with retries, fallbacks, timeouts, and monitoring. AI is no different, except that it fails in more interesting ways.

Cost, latency, and SLAs

These three are linked, and B2B AI features live or die on managing them together.

Latency. Model calls are slow — hundreds of milliseconds to several seconds. If the feature is in a user's hot path, that's latency they feel against a product that's otherwise fast. The levers: stream responses so the user sees output immediately; cache aggressively, since B2B workloads repeat queries far more than consumer ones; and keep AI off the synchronous path where you can — run it as a background job and notify on completion when the use case allows. Set a hard timeout on every model call. A request that hangs for thirty seconds is worse than one that fails in three and falls back.

Cost. Per-request cost that's trivial in a demo becomes a budget line at enterprise volume, and unlike your fixed infrastructure it scales linearly with usage. Control it: cache repeated requests, route simple tasks to smaller cheaper models and reserve the expensive model for what needs it, cap per-tenant spend so one customer's runaway usage can't blow the month, and track cost per tenant and per feature so you can price and forecast. Unmonitored AI cost is how a feature ships profitable and turns into a loss by quarter's end.

SLA. Your product promises uptime. The model provider has outages that don't care about your promise. The architecture has to deliver your SLA despite an undependable dependency — which means fallbacks and degradation, below, are not nice-to-haves. They're how you keep the number you signed.

Multi-tenant data isolation for AI

This is the part that's genuinely new and genuinely dangerous. Your product already isolates tenant data in the database. AI features introduce new paths for that isolation to break, and a leak here is a breach with your biggest customers' data in it.

Retrieval isolation. If you build a vector store for retrieval, tenant data lives in it as embeddings. Tenant A's query must never retrieve Tenant B's chunks. Enforce isolation in the index — per-tenant partitions or mandatory tenant-ID filtering on every query, applied as a hard gate, never as a hope. A semantic search that crosses tenant boundaries is a data breach that happens to look like a relevance bug.

Context isolation. Never assemble a single prompt with data from multiple tenants. The model has no concept of your tenant boundaries; whatever lands in the context window is fair game to surface. The boundary is enforced before the context is built, not after.

No training on tenant data without explicit terms. If you fine-tune or otherwise learn from tenant data, one tenant's data must never influence another's outputs, and your contracts and data-handling have to reflect what you actually do. Enterprise buyers ask this in security review, and the honest answer has to be architecturally true.

Provider data handling. Where does tenant data go when you call the model provider — is it retained, is it trained on, is it in a region your customer's compliance allows. Your DPA and your provider choice have to line up with what you promise. This shows up in every enterprise security questionnaire.

Observability for AI features

You can't operate what you can't see, and AI features fail quietly — quality degrades without throwing an error. Standard APM doesn't capture it. You instrument:

  • Quality, sampled and graded — accuracy, grounding, abstention rate — so you catch the slow degradation that no exception surfaces.
  • Latency, per stage (retrieval, model, validation), so you know where it's slow, not just that it is.
  • Cost, per request, per tenant, per feature — live, not reconstructed from the provider bill weeks later.
  • Errors and fallbacks — model timeouts, provider outages, validation rejections, and how often you fell back. A rising fallback rate is a provider problem you want to see before customers do.
  • The inputs and outputs of sampled requests (with tenant data handled per your privacy rules), because debugging a nondeterministic system without seeing what it actually did is guessing.

Graceful degradation

The model provider will have an outage. It is not an edge case; it is a scheduled certainty. The question the architecture answers is what your product does in that window.

The wrong answer is a broken feature throwing errors at enterprise customers. The right answer is degradation: fall back to a secondary provider, or to a smaller self-hosted model, or to a cached or non-AI experience that still does something useful. A document tool whose AI summary is down can still show the document. A search whose semantic layer is down can still serve lexical results. The feature gets quietly worse, not broken, and the customer's workflow survives.

This is why AI calls route through a gateway with provider abstraction. When one provider fails, you reroute in that one service instead of editing twelve call sites mid-incident. The product keeps its promise because the architecture planned for the dependency to fail.

What fixed looks like

AI features that meet the same bar as the rest of your product. Model calls route through a gateway service with retries, timeouts, caching, fallbacks, and cost controls. Retrieval is multi-tenant isolated, enforced in the index. Outputs pass a validation and guardrail layer before reaching a customer. Everything is observable — quality, latency, cost, errors — per tenant and per feature. When a provider goes down, the feature degrades gracefully and the product keeps serving.

Cost is tracked and capped, so AI features stay profitable at scale. Tenant isolation holds through the AI paths, so security review passes and no customer's data surfaces in another's results. The AI feature isn't graded on a curve, because it doesn't need one — it hits the same reliability standard as everything else you ship.

This is for you if

You're adding AI to a real B2B SaaS product that has enterprise customers, SLAs, security reviews, and a reliability bar the AI has to clear. The architecture work — gateway service, multi-tenant retrieval isolation, validation and guardrails, observability, and graceful degradation — runs $100k+, scaling with the number of AI surfaces, tenant-isolation complexity, and how strict your uptime and compliance commitments are.

This is not for you if you're pre-revenue and validating whether anyone wants the AI feature at all. Build the prototype, skip this architecture, learn fast, and come back when it has to be reliable. And it's not for you if you're comfortable grading the AI feature on a curve your enterprise customers didn't agree to — that gap closes itself the first time a provider outage takes down a feature during a customer's workday, and we'd rather build it so that day is a non-event.