---
title: "Install Mem0"
description: "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..."
last_updated: "2026-05-07T04:49:20.042036+00:00"
canonical_url: "https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/guide/section-1/install-mem0"
---

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.

## Installation and Setup

You can get started with Mem0 in two primary ways: using the hosted platform or installing the open-source SDK for self-hosting.

<Steps>
<Step>
### Choose your setup method

Decide whether you want to use the fully managed Hosted Platform or the Self-Hosted (Open Source) SDK.

<Callout variant="info">
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.
</Callout>
</Step>

<Step>
### Set up the Hosted Platform

If you choose the Hosted Platform, follow these steps:

1.  **Sign up**: Visit the [Mem0 Platform](https://app.mem0.ai) and create an account.
2.  **Embed**: Integrate the memory layer into your application using the provided SDK or API keys.
</Step>

<Step>
### Install the Self-Hosted SDK

If you prefer to self-host, you can install the Mem0 SDK using either `pip` (for Python) or `npm` (for Node.js).

<Tabs items={["Python (pip)", "Node.js (npm)"]}>
<Tab value="Python (pip)">
To install the Python SDK, open your terminal or command prompt and run:

```bash
pip install mem0ai
```
</Tab>
<Tab value="Node.js (npm)">
To install the Node.js SDK, open your terminal or command prompt and run:

```bash
npm install mem0ai
```
</Tab>
</Tabs>
</Step>

<Step>
### Basic Usage (Python Example)

After 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:

```python
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()
```

<Callout variant="info">
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](https://docs.mem0.ai/components/llms/overview).
</Callout>
</Step>
</Steps>

### Key Concepts

*   **Memory Object**: The `Memory()` object is your main interface for interacting with Mem0. You use it to store, retrieve, update, and delete memories.
*   **User ID**: The `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.
*   **LLM (Large Language Model)**: Mem0 works by integrating with an LLM. It uses the LLM to understand context, generate responses, and process memories. You'll need to configure an LLM for Mem0 to function.

## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/llms.txt) for all pages in this wiki.
