Home/Documentation

Python SDK Quickstart

Get started with MemoAir in under 5 minutes.

Prerequisites

Installation

BASH
pip install memoair

1. Initialize the Client

Import the library and initialize the client with your API key.

main.py
PYTHON
import os
from memoair import MemoAir
 
# Initialize the client
# You can pass the key directly or set MEMOAIR_API_KEY env var
client = MemoAir(api_key="memoair_sk_...")

2. Add Memories

Store a conversation to extract facts and context automatically.

main.py
PYTHON
from memoair import Message
 
# Add conversation to memory
client.memories.add(
group_id="user:john",
messages=[
Message(content="I'm a Python developer", role_type="user", role="John"),
Message(content="Nice! What frameworks do you use?", role_type="assistant"),
Message(content="I mainly use FastAPI and PyTorch", role_type="user", role="John"),
],
)

3. Search Memories

Query the knowledge graph to retrieve relevant facts.

main.py
PYTHON
# Search memories
results = client.search.query(
query="What programming languages does John use?",
group_ids=["user:john"],
)
 
for fact in results.facts:
print(f"- {fact.fact}")
 
# Output:
# - John is a Python developer
# - John uses FastAPI and PyTorch

Next Steps