> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Mem0Storage

> Mem0 Platform and Open Source integration

## Overview

`Mem0Storage` integrates with the Mem0 memory platform. Supports both the hosted Mem0 Platform and self-hosted Mem0 Open Source deployments.

## Install

<Note>
  Install the Mem0 storage optional dependency group:

  ```bash theme={null}
  uv pip install "upsonic[mem0-storage]"
  ```
</Note>

## Basic Usage

```python theme={null}
from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.mem0 import Mem0Storage

storage = Mem0Storage(
    api_key="your_mem0_api_key",
    org_id="your_org_id",
    project_id="your_project_id"
)

memory = Memory(
    storage=storage,
    session_id="session_001",
    user_id="user_123",
    full_session_memory=True,
    summary_memory=True,
    user_analysis_memory=True,
    model="anthropic/claude-sonnet-4-5"
)

agent = Agent("anthropic/claude-sonnet-4-5", memory=memory)

result1 = agent.do(Task("My name is Alice"))
result2 = agent.do(Task("What's my name?"))
print(result2)  # "Your name is Alice"
```

## Parameters

| Parameter                  | Type                             | Default                        | Description                                           |
| -------------------------- | -------------------------------- | ------------------------------ | ----------------------------------------------------- |
| `memory_client`            | `Memory \| MemoryClient \| None` | `None`                         | Pre-existing Mem0 client                              |
| `api_key`                  | `str \| None`                    | `None`                         | Mem0 Platform API key                                 |
| `host`                     | `str \| None`                    | `None`                         | Mem0 Platform host URL                                |
| `org_id`                   | `str \| None`                    | `None`                         | Organization ID (Platform)                            |
| `project_id`               | `str \| None`                    | `None`                         | Project ID (Platform)                                 |
| `config`                   | `MemoryConfig \| None`           | `None`                         | Config for self-hosted Mem0                           |
| `session_table`            | `str \| None`                    | `"upsonic_sessions"`           | Session table name (metadata)                         |
| `user_memory_table`        | `str \| None`                    | `"upsonic_user_memories"`      | User memory table name (metadata)                     |
| `knowledge_table`          | `str \| None`                    | `"upsonic_knowledge"`          | Knowledge registry table name (used by KnowledgeBase) |
| `cultural_knowledge_table` | `str \| None`                    | `"upsonic_cultural_knowledge"` | Cultural knowledge table name                         |
| `default_user_id`          | `str`                            | `"upsonic_default"`            | Default user ID for Mem0 operations                   |
| `id`                       | `str \| None`                    | auto-generated                 | Storage instance ID                                   |
