# LongMem > Privacy-first long-term memory API for AI agents and apps. Store text and files, > search them semantically (vector + full-text hybrid), and let memory evolve over > time (automatic fact extraction, updates/supersedes relationships, forgetting). > Self-hostable; your data never leaves the box when run on-prem. Multi-tenant with > strict per-tenant isolation. Base URL: https://longmem.dev Full reference: https://longmem.dev/llms-full.txt Auth: every request sends `Authorization: Bearer mv_...` (your API key). Content type: `application/json` unless uploading files. ## Core concepts - **Collection**: a named namespace for memories (e.g. `prefs`, `people`, `docs`). - **Memory**: a stored item (text, optionally with files/images) + metadata. - **Search**: hybrid (vector + keyword) by default; also `vector` or `text` only. - **Graph memory**: `/remember` extracts atomic facts and links updates/supersedes, so the latest truth wins; old facts can expire and be forgotten automatically. ## Quickest start (Python SDK, zero dependencies) ```python from longmem import Longmem # pip install longmem-sdk (publish pending; see Source) mem = Longmem() # reads LONGMEM_API_KEY mem.add("Alex prefers dark mode", collection="prefs") print(mem.search("what theme does Alex like?")) ``` ## Key endpoints Store a memory: ``` POST /v1/memory/collections/{collection}/memories { "text": "Alex prefers dark mode", "importance": 0.7, "category": "preference", "metadata": {} } ``` Search within a collection: ``` POST /v1/memory/collections/{collection}/search { "query": "what theme does Alex like?", "limit": 5, "mode": "hybrid" } ``` Search across all collections: ``` POST /v1/memory/search { "query": "...", "limit": 5 } ``` Graph memory — extract + relate facts from free text: ``` POST /v1/memory/collections/{collection}/remember { "content": "Alex moved from Google to Stripe last month." } ``` Build a profile summary of a collection: ``` GET /v1/memory/collections/{collection}/profile ``` List collections: ``` GET /v1/memory/collections ``` ## curl example ``` curl -s https://longmem.dev/v1/memory/collections/prefs/search \ -H "Authorization: Bearer $LONGMEM_API_KEY" -H "Content-Type: application/json" \ -d '{"query":"what theme does the user like?","limit":5}' ``` ## MCP (Model Context Protocol) LongMem speaks MCP at `POST /v1/mcp` (JSON-RPC) with tools `search_memory`, `get_memory`, `store_memory`, `list_collections` — point an MCP-capable agent at it with your bearer key. ## One-prompt agent onboarding Paste this into Claude Code or Cursor to wire memory into your project: > Use the LongMem memory API at https://longmem.dev. Read the bearer key from the > LONGMEM_API_KEY env var. Before answering, search relevant memory with > `POST /v1/memory/search {"query": }`. After learning a durable fact > about the user or project, store it with > `POST /v1/memory/collections/project/memories {"text": }`. Prefer the > `longmem` Python SDK if available. ## Links - Docs: https://longmem.dev/docs.html - Source: https://github.com/11data/longmem