# Memobase

> User-profile-based long-term memory backend for LLM chatbots and assistants

- Category: Agents & Automation / Agent Memory
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/memodb-io/memobase
- Website: https://www.memobase.io
- Canonical page: https://ai-tldr.dev/tools/memobase/

## In short

Memobase is an open-source memory backend that gives LLM applications long-term memory about each user. Instead of storing raw conversation logs, it builds a structured user profile (name, interests, work, demographics, and more) plus a time-stamped event timeline that grows as the user keeps chatting. It sits in the Agent Memory category of the Agents & Automation tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Memobase is an open-source memory backend that gives LLM applications long-term memory about each user. Instead of storing raw conversation logs, it builds a structured user profile (name, interests, work, demographics, and more) plus a time-stamped event timeline that grows as the user keeps chatting.

It is aimed at developers building virtual companions, educational tools, and personalized assistants who need their AI to remember a user across sessions. You send conversations to Memobase, it processes them in a per-user buffer, and you read back a compact profile or a ready-to-use context block to drop into your prompt.

As a memory framework, Memobase focuses on the user rather than the agent. It runs as a server built on FastAPI, Postgres, and Redis, and offers SDKs for Python, Node, and Go plus a REST API, so it slots into an existing LLM stack with small code changes.

## What it does

- Builds a structured, controllable user profile with topics and sub-topics learned from chats
- Records a time-aware event timeline so the assistant can answer time-related questions
- Batches each user's conversations in a buffer, then flushes them to memory to keep cost and latency down
- Returns a profile or a packed context block you can insert directly into your prompt
- SDKs for Python, Node, and Go, plus a REST API and an MCP server
- Self-hostable via Docker (FastAPI, Postgres, Redis) or a hosted cloud free tier

## Getting started

Run a Memobase server (self-hosted or the hosted cloud free tier), then connect with the Python SDK to add a user, insert a chat, flush, and read the profile.

1. Install the SDK and connect

   Install the Python client, then create a client with your project URL and token and confirm the connection. Local defaults are http://localhost:8019 with the token secret.

```bash
pip install memobase
```

2. Connect to your project

   Point the client at your project URL and API key, then ping to verify.

```python
from memobase import MemoBaseClient, ChatBlob

client = MemoBaseClient(
    project_url=PROJECT_URL,
    api_key=PROJECT_TOKEN,
)
assert client.ping()
```

3. Add a user and insert a chat

   Create a user, then insert a conversation as a ChatBlob. Memobase processes blobs into memory and removes them by default once handled.

```python
uid = client.add_user({"any_key": "any_value"})
u = client.get_user(uid)

messages = [
  {"role": "user", "content": "Hello, I'm Gus"},
  {"role": "assistant", "content": "Hi, nice to meet you, Gus!"},
]
bid = u.insert(ChatBlob(messages=messages))
```

4. Flush and read the profile

   Flush the buffer (use sync=True to wait for processing), then read the structured profile the user has learned.

```python
u.flush(sync=True)
print(u.profile(need_json=True))
```

## When to use it

- Give a virtual companion or chatbot persistent memory so it remembers a user's name, interests, and history across sessions
- Personalize an AI assistant's answers using a structured profile packed into the prompt context
- Answer time-related questions by querying the user's event timeline
- Track and analyze what your AI learns about users over many conversations
