Multitenancy

Learn how to organize and manage data for multiple tenants in RAGaaS.

Overview

RAGaaS supports multitenancy through two primary mechanisms:

  1. Namespaces: For complete data isolation between tenants
  2. Metadata: For flexible tenant-specific organization within namespaces

Choosing Your Approach

Namespace-Based Isolation

Best for organizations that need:

  • Complete data isolation between tenants
  • Separate infrastructure per tenant
  • Independent scaling and billing
  • Compliance with data residency

Not suitable when:

  • Content sharing between tenants is required
  • Cost optimization is priority
  • Managing many small tenants

Metadata-Based Organization

Best for organizations that need:

  • Shared infrastructure across tenants
  • Flexible content sharing
  • Cost-effective solution
  • Simple tenant management

Not suitable when:

  • Strict data isolation is required
  • Compliance requires separate infrastructure

Implementation

Using Namespaces

Create a dedicated namespace for each tenant:

curl -X POST https://api.ragaas.dev/v1/namespaces \
  -H "Authorization: Bearer $RAGAAS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "tenant1-production",
    "fileStorageConfig": {
      "provider": "S3",
      "bucket": "tenant1-docs",
      "region": "us-east-1",
      "credentials": {
        "accessKeyId": "...",
        "secretAccessKey": "..."
      }
    },
    "vectorStorageConfig": {
      "provider": "PINECONE",
      "apiKey": "...",
      "indexHost": "tenant1.pinecone.io"
    },
    "embeddingModelConfig": {
      "provider": "OPENAI",
      "model": "text-embedding-3-small",
      "apiKey": "..."
    }
  }'

Using Metadata

Add tenant information during document ingestion:

curl -X POST https://api.ragaas.dev/v1/ingest/text \
  -H "Authorization: Bearer $RAGAAS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "namespaceId": "shared-namespace",
    "ingestConfig": {
      "source": "TEXT",
      "config": {
        "text": "Company policy document...",
        "metadata": {
          "tenantId": "tenant-123",
          "department": "hr",
          "accessLevel": "internal",
          "region": "us-west"
        }
      }
    }
  }'

Filter content by tenant metadata:

curl -X POST https://api.ragaas.dev/v1/search \
  -H "Authorization: Bearer $RAGAAS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "company policy",
    "namespaceId": "shared-namespace",
    "filter": {
      "metadata": {
        "tenantId": "tenant-123",
        "accessLevel": "internal"
      }
    }
  }'

Best Practices

  1. Organization

    • Use clear naming conventions (e.g., {tenant}-{environment})
    • Define consistent metadata schema
    • Separate production and non-production environments
  2. Security

    • Implement tenant validation in your application
    • Use metadata for access control
    • Consider regulatory requirements
  3. Performance

    • Monitor resource usage per namespace
    • Use appropriate metadata indexing
    • Consider tenant size when choosing approach