Self-Hosted Multi-Tenant RAG Application
Build a production multi-tenant RAG app with tenant-scoped TypeGraph clients, document ingest, events, and search.
Cache Clients by Tenant
Create one TypeGraph client per customer tenant. In Cloud, API-key auth resolves your TypeGraph organization, while tenantId selects the customer graph. In self-hosted mode, the same pattern works with your own adapter config.
Require X-Tenant-Id
API routes should require X-Tenant-Id. Do not expose tenant choice as organization ID or as a top-level body field. If internal SDK payloads carry identity.tenantId, validate that it matches the header.
Ingest Documents
Document ingest should call typegraph.document.ingest() and pass all per-call identity and write access under context.
Search Tenant Data
Search always runs inside the tenant-bound client. context narrows readable records; resources and weights control retrieval and scoring.