Skip to main content

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.

Overview

AsyncMem0Storage provides asynchronous integration with the Mem0 memory platform. Supports both the hosted Mem0 Platform (AsyncMemoryClient) and self-hosted Mem0 Open Source (AsyncMemory) deployments.

Install

Install the Mem0 storage optional dependency group:
uv pip install "upsonic[mem0-storage]"

Basic Usage

import asyncio
from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.mem0 import AsyncMem0Storage

async def main():
    storage = AsyncMem0Storage(
        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 = await agent.do_async(Task("My name is Alice"))
    result2 = await agent.do_async(Task("What's my name?"))
    print(result2)  # "Your name is Alice"

asyncio.run(main())

Parameters

ParameterTypeDefaultDescription
memory_clientAsyncMemory or AsyncMemoryClientNonePre-configured async Mem0 client
api_keystrNoneMem0 Platform API key (or use MEM0_API_KEY env var)
hoststrNoneMem0 Platform host URL
org_idstrNoneMem0 Platform organization ID
project_idstrNoneMem0 Platform project ID
configMemoryConfigNoneConfiguration for self-hosted AsyncMemory
session_tablestrNoneCustom name for the session table (used in metadata)
user_memory_tablestrNoneCustom name for the user memory table
knowledge_tablestrNoneCustom name for the knowledge registry table (used by KnowledgeBase)
cultural_knowledge_tablestrNoneCustom name for the cultural knowledge table
default_user_idstr"upsonic_default"Default user ID for Mem0 operations
idstrNoneUnique identifier for this storage instance

Self-Hosted Usage

import asyncio
from mem0 import AsyncMemory
from mem0.configs.base import MemoryConfig
from upsonic.storage.mem0 import AsyncMem0Storage

async def main():
    # Option 1: With custom config
    config = MemoryConfig(...)
    storage = AsyncMem0Storage(config=config)

    # Option 2: With existing client
    memory_client = AsyncMemory()
    storage = AsyncMem0Storage(memory_client=memory_client)

asyncio.run(main())