> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory Operations

> Create, update, list, and delete user memories

**1. Create a Python file**

```python memory_operations.py theme={null}
import asyncio

from agno.client import AgentOSClient


async def main():
    client = AgentOSClient(base_url="http://localhost:7777")
    user_id = "example-user"

    print("=" * 60)
    print("Memory Operations")
    print("=" * 60)

    # Create a memory
    print("\n1. Creating a memory...")
    memory = await client.create_memory(
        memory="User prefers dark mode for all applications",
        user_id=user_id,
        topics=["preferences", "ui"],
    )
    print(f"   Created memory: {memory.memory_id}")
    print(f"   Content: {memory.memory}")
    print(f"   Topics: {memory.topics}")

    # List memories for the user
    print("\n2. Listing memories...")
    memories = await client.list_memories(user_id=user_id)
    print(f"   Found {len(memories.data)} memories for user {user_id}")
    for mem in memories.data:
        print(f"   - {mem.memory_id}: {mem.memory[:50]}...")

    # Get a specific memory
    print(f"\n3. Getting memory {memory.memory_id}...")
    retrieved = await client.get_memory(memory.memory_id, user_id=user_id)
    print(f"   Memory: {retrieved.memory}")

    # Update the memory
    print("\n4. Updating memory...")
    updated = await client.update_memory(
        memory_id=memory.memory_id,
        memory="User strongly prefers dark mode for all applications and websites",
        user_id=user_id,
        topics=["preferences", "ui", "accessibility"],
    )
    print(f"   Updated memory: {updated.memory}")
    print(f"   Updated topics: {updated.topics}")

    # Delete the memory
    print(f"\n5. Deleting memory {memory.memory_id}...")
    await client.delete_memory(memory.memory_id, user_id=user_id)
    print("   Memory deleted")


if __name__ == "__main__":
    asyncio.run(main())
```

<Snippet file="create-venv-step.mdx" />

**2. Install dependencies**

```bash theme={null}
uv pip install -U agno openai
```

**3. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**4. Start an AgentOS Server**

Start the [client example server](https://agno-v2.mintlify.site/examples/agent-os/python-client/-server.md) on port 7777. It registers an agent with `update_memory_on_run=True` and a SQLite database for memories.

**5. Run the Client**

```bash Mac theme={null}
python memory_operations.py
```

```bash Windows theme={null}
python memory_operations.py
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.