Tanstack ai memory mem0

From TanStack/ai · View interactive version

Tanstack ai memory mem0 is an AI agent skill from the GitHub repository TanStack/ai. Use when wiring mem0() from @tanstack/ai-memory/mem0 — a hosted memory adapter that talks to a mem0 server over plain HTTP (no SDK peer). Requires a running mem0 server.

How to use this skill

Skill file

mem0 Memory Adapter

Hosted recall/save adapter backed by a mem0 server. mem0 owns extraction and ranking

server-side. Talks to the server over plain HTTP — no SDK peer dependency.

Setup

import { memoryMiddleware } from '@tanstack/ai-memory'
import { mem0 } from '@tanstack/ai-memory/mem0'

// Build per request from the server-validated session — never from req.body.
function memoryFor(session: { userId: string; threadId: string }) {
  const memory = mem0({ user: session.userId }) // baseUrl defaults to MEM0_URL

  return memoryMiddleware({
    adapter: memory,
    scope: { threadId: session.threadId, userId: session.userId },
  })
}

Requires a running mem0 server (self-hosted or hosted). Point it via baseUrl (or

MEM0_URL); pass apiKey (or MEM0_ADMIN_API_KEY) when secured.

Options

Scope fields: requests send user_id and run_id (scope.threadId). tenantId

and namespace are not sent — encode multi-tenant isolation into user if needed.

save posts the { user, assistant } turn to /memories; recall queries /search

and renders the results into the system prompt. mem0 exposes no LLM tools.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.