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

# Memory Operations

> Create, update, list, and delete user memories

<Steps>
  <Step title="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())
    ```
  </Step>

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```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"
      ```
    </CodeGroup>
  </Step>

  <Step title="Start an AgentOS Server">
    Make sure you have an AgentOS server running with `update_memory_on_run=True` configured on an agent. See [Creating Your First OS](/agent-os/run-your-os) for setup instructions.
  </Step>

  <Step title="Run the Client">
    <CodeGroup>
      ```bash Mac theme={null}
      python memory_operations.py
      ```

      ```bash Windows theme={null}
      python memory_operations.py
      ```
    </CodeGroup>
  </Step>
</Steps>
