Getting Started
Core Features
How-To Guides
Configuration
Troubleshooting
Integrations
Mem0 ("mem-zero") provides an intelligent memory layer for AI applications, allowing them to remember user preferences, adapt to individual needs, and continuously learn over time. This enhances AI assistants and agents by enabling personalized interactions, making them ideal for applications like customer support chatbots, AI assistants, and autonomous systems.
With Mem0, your AI can maintain consistent, context-rich conversations, recall past interactions for tailored help, and adapt workflows based on user behavior. It offers both a hosted platform for quick setup and a self-hosted option for full control.
You can get started with Mem0 in two primary ways: using the hosted platform or installing the open-source SDK for self-hosting.
Decide whether you want to use the fully managed Hosted Platform or the Self-Hosted (Open Source) SDK.
The Hosted Platform offers automatic updates, analytics, and enterprise security, getting you up and running in minutes. The Self-Hosted option gives you full control over your environment.
If you choose the Hosted Platform, follow these steps:
If you prefer to self-host, you can install the Mem0 SDK using either pip (for Python) or (for Node.js).
Memory() object is your main interface for interacting with Mem0. You use it to store, retrieve, update, and delete memories.user_id parameter is crucial for personalization. It allows Mem0 to associate memories with specific users, ensuring that each user's AI experience is tailored to their past interactions.npmTo install the Python SDK, open your terminal or command prompt and run:
pip install mem0aiAfter installation, you can start using Mem0 to manage memories for your AI. Mem0 requires a Large Language Model (LLM) to function, with gpt-4.1-nano-2025-04-14 from OpenAI as the default.
Here's a basic Python example demonstrating how to initialize Mem0, retrieve relevant memories, generate a response using an LLM, and then add new memories from the conversation:
from openai import OpenAI
from mem0 import Memory
# Initialize your OpenAI client (or any other LLM client)
openai_client = OpenAI()
# Initialize Mem0 Memory
memory = Memory()
def chat_with_memories(message: str, user_id: str = "default_user") -> str:
# 1. Retrieve relevant memories for the current user and message
relevant_memories = memory.search(query=message, user_id=user_id, limit=3)
memories_str = "\n".join(f"- {entry['memory']}" for entry in relevant_memories["results"])
# 2. Prepare the system prompt with retrieved memories
system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
# 3. Generate an AI response using the LLM
response = openai_client.chat.completions.create(model="gpt-4.1-nano-2025-04-14", messages=messages)
assistant_response = response.choices[0].message.content
# 4. Add the conversation (user message + AI response) as new memories
messages.append({"role": "assistant", "content": assistant_response})
memory.add(messages, user_id=user_id)
return assistant_response
def main():
print("Chat with AI (type 'exit' to quit)")
while True:
user_input = input("You: ").strip()
if user_input.lower() == 'exit':
print("Goodbye!")
break
print(f"AI: {chat_with_memories(user_input)}")
if __name__ == "__main__":
main()This example uses OpenAI's gpt-4.1-nano-2025-04-14 as the LLM. Mem0 supports a variety of LLMs. For a complete list and configuration details, refer to the Supported LLMs documentation.