Python SDK Quickstart
Get started with MemoAir in under 5 minutes.
Prerequisites
- Python 3.9 or higher
- A MemoAir API Key (contact support to get one)
Installation
pip install memoair
1. Initialize the Client
Import the library and initialize the client with your API key.
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.
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.
# 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