memories.sh logomemories.sh
SDK

AI SDK Projects

Create SaaS-scoped SDK projects in the dashboard and avoid tenantId vs projectId confusion.

Use this page first if you are wiring memories.sh into a SaaS app.

SaaS apps using SDK endpoints (/api/sdk/v1/*) do not need MCP multitenancy. Use MCP routing only when you are serving MCP-native clients.

What is an AI SDK Project?

In the dashboard, an AI SDK Project is a tenantId boundary that routes to an isolated memory database.

  • One project per customer workspace, org, environment, or app surface
  • Works for solo devs and teams
  • Created in your currently selected dashboard workspace

Setup Flow (Dashboard)

  1. Open Dashboard → AI SDK Projects.
  2. Generate a mem_... API key.
  3. Use backend-derived tenantId values in SDK requests.
  4. Runtime provisions or resolves tenant DBs automatically on first use (when server provisioning is enabled).
  5. Use Tenant Overrides only for explicit DB attachment/provisioning control.

Scope Cheat Sheet

Scope fieldWhat it isolatesSecurity boundaryRequired
tenantIdSaaS customer/project databaseYesFor multi-tenant SaaS
userIdEnd-user scope inside tenantIdYes (within tenant)Optional
projectIdOptional git/repo context filterNoOptional

Important: tenantId vs projectId

These are different:

  • tenantId = SaaS isolation boundary (database routing)
  • userId = end-user scope inside tenantId
  • projectId = optional repo context filter (for coding assistants)

If your app is not git-centric, omit projectId.

Solo Dev Guidance

You do not need a team workspace to start.

  • Stay in your personal workspace.
  • Create AI SDK Projects there.
  • Add team workspace later if needed.

Server-Side Usage Pattern

Always derive scope in backend auth code, then call memories with your server key.

const client = new MemoriesClient({
  apiKey: process.env.MEMORIES_API_KEY,
  tenantId: auth.orgId, // server-derived
  userId: auth.userId,  // server-derived
})

const context = await client.context.get({
  query: "pricing and billing policy",
  projectId: undefined, // optional git context filter
})

Next: SaaS Auth Routing

On this page