https://github.com/mem0ai/mem0
The Memory layer for AI Agents
https://github.com/mem0ai/mem0
agent ai aiagent application chatbots chatgpt embeddings llm long-term-memory memory memory-management python rag state-management vector-database
Last synced: about 15 hours ago
JSON representation
The Memory layer for AI Agents
- Host: GitHub
- URL: https://github.com/mem0ai/mem0
- Owner: mem0ai
- License: apache-2.0
- Created: 2023-06-20T08:58:36.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-14T15:38:49.000Z (9 days ago)
- Last Synced: 2025-04-15T13:48:15.478Z (8 days ago)
- Topics: agent, ai, aiagent, application, chatbots, chatgpt, embeddings, llm, long-term-memory, memory, memory-management, python, rag, state-management, vector-database
- Language: Python
- Homepage: https://mem0.ai
- Size: 34.6 MB
- Stars: 27,543
- Watchers: 148
- Forks: 2,618
- Open Issues: 300
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome - mem0ai/mem0 - The Memory layer for AI Agents (Python)
- alan_awesome_llm - Mem0
- awesome-ChatGPT-repositories - mem0 - Long-term memory for LLMs (NLP)
- awesome-repositories - mem0ai/mem0 - The Memory layer for your AI apps (Python)
- my-awesome-list - mem0
- Awesome-AI-Agents - mem0 - Mem0 provides a smart, self-improving memory layer for Large Language Models, enabling personalized AI experiences across applications.  (Applications / Advanced Components)
- Awesome-AI-Agents - mem0 - Mem0 provides a smart, self-improving memory layer for Large Language Models, enabling personalized AI experiences across applications.  (Applications / Advanced Components)
- awesome - mem0ai/mem0 - The Memory layer for AI Agents (Python)
- jimsghstars - mem0ai/mem0 - The Memory layer for your AI apps (Python)
- AiTreasureBox - mem0ai/mem0 - 04-15_27513_1](https://img.shields.io/github/stars/mem0ai/mem0.svg)|The memory layer for Personalized AI| (Repos)
- awesome-LLM-resourses - Mem0
- alan_awesome_llm - Mem0
- awesome_ai_agents - mem0 - Mem0 is an intelligent memory layer for Large Language Models that enhances personalized AI experiences by retaining and utilizing contextual information across various applications. [github](https://github.com/mem0ai/mem0) | [website](https://app.mem0.ai/) | [docs](https://docs.mem0.ai/) | [discord](https://mem0.ai/discord) | [twitter](https://x.com/mem0ai) | [github profile](https://github.com/mem0ai) | [linkedin](https://www.linkedin.com/company/mem0/) (Learning / Repositories)
- Awesome-LLMOps - Mem0 - commit/mem0ai/mem0?color=green) (Agent / Tools)
- Awesome-LLMOps - Mem0
- awesome-production-machine-learning - Mem0 - Mem0 enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. (Industry Strength Information Retrieval)
README
Learn more
·
Join Discord
·
Demo
# Introduction
[Mem0](https://mem0.ai) (pronounced as "mem-zero") enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. Mem0 remembers user preferences, adapts to individual needs, and continuously improves over time, making it ideal for customer support chatbots, AI assistants, and autonomous systems.
### Features & Use Cases
Core Capabilities:
- **Multi-Level Memory**: User, Session, and AI Agent memory retention with adaptive personalization
- **Developer-Friendly**: Simple API integration, cross-platform consistency, and hassle-free managed serviceApplications:
- **AI Assistants**: Seamless conversations with context and personalization
- **Learning & Support**: Tailored content recommendations and context-aware customer assistance
- **Healthcare & Companions**: Patient history tracking and deeper relationship building
- **Productivity & Gaming**: Streamlined workflows and adaptive environments based on user behavior## Get Started
Get started quickly with [Mem0 Platform](https://app.mem0.ai) - our fully managed solution that provides automatic updates, advanced analytics, enterprise security, and dedicated support. [Create a free account](https://app.mem0.ai) to begin.
For complete control, you can self-host Mem0 using our open-source package. See the [Quickstart guide](#quickstart) below to set up your own instance.
Install the Mem0 package via pip:
```bash
pip install mem0ai
```Install the Mem0 package via npm:
```bash
npm install mem0ai
```### Basic Usage
Mem0 requires an LLM to function, with `gpt-4o-mini` from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our [Supported LLMs documentation](https://docs.mem0.ai/llms).
First step is to instantiate the memory:
```python
from openai import OpenAI
from mem0 import Memoryopenai_client = OpenAI()
memory = Memory()def chat_with_memories(message: str, user_id: str = "default_user") -> str:
# Retrieve relevant memories
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"])
# Generate Assistant response
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}]
response = openai_client.chat.completions.create(model="gpt-4o-mini", messages=messages)
assistant_response = response.choices[0].message.content# Create new memories from the conversation
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()
```See the example for [Node.js](https://docs.mem0.ai/examples/ai_companion_js).
For more advanced usage and API documentation, visit our [documentation](https://docs.mem0.ai).
> [!TIP]
> For a hassle-free experience, try our [hosted platform](https://app.mem0.ai) with automatic updates and enterprise features.## Demos
- Mem0 - ChatGPT with Memory: A personalized AI chat app powered by Mem0 that remembers your preferences, facts, and memories.
[Mem0 - ChatGPT with Memory](https://github.com/user-attachments/assets/cebc4f8e-bdb9-4837-868d-13c5ab7bb433)
Try live [demo](https://mem0.dev/demo/)
- AI Companion: Experience personalized conversations with an AI that remembers your preferences and past interactions
[AI Companion Demo](https://github.com/user-attachments/assets/3fc72023-a72c-4593-8be0-3cee3ba744da)
- Enhance your AI interactions by storing memories across ChatGPT, Perplexity, and Claude using our browser extension. Get [chrome extension](https://chromewebstore.google.com/detail/mem0/onihkkbipkfeijkadecaafbgagkhglop?hl=en).
[Chrome Extension Demo](https://github.com/user-attachments/assets/ca92e40b-c453-4ff6-b25e-739fb18a8650)
- Customer support bot using Langgraph and Mem0. Get the complete code from [here](https://docs.mem0.ai/integrations/langgraph)
[Langgraph: Customer Bot](https://github.com/user-attachments/assets/ca6b482e-7f46-42c8-aa08-f88d1d93a5f4)
- Use Mem0 with CrewAI to get personalized results. Full example [here](https://docs.mem0.ai/integrations/crewai)
[CrewAI Demo](https://github.com/user-attachments/assets/69172a79-ccb9-4340-91f1-caa7d2dd4213)
## Documentation
For detailed usage instructions and API reference, visit our [documentation](https://docs.mem0.ai). You'll find:
- Complete API reference
- Integration guides
- Advanced configuration options
- Best practices and examples
- More details about:
- Open-source version
- [Hosted Mem0 Platform](https://app.mem0.ai)## Support
Join our community for support and discussions. If you have any questions, feel free to reach out to us using one of the following methods:
- [Join our Discord](https://mem0.dev/DiG)
- [Follow us on Twitter](https://x.com/mem0ai)
- [Email founders](mailto:founders@mem0.ai)## License
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.