Python SDK Quickstart
Get started with MemoAir in under 5 minutes.
Prerequisites
- Python 3.9 or higher
- A MemoAir API key — sign up and generate one for free from dashboard.memoair.space.
Installation
BASH
pip install memoair1. Initialize the Client
Import the library and initialize the client with your API key.
main.py
PYTHONimport osfrom memoair import MemoAir # Initialize the client# You can pass the key directly or set MEMOAIR_API_KEY env varclient = MemoAir(api_key="memoair_sk_...")2. Add Memories
Store a conversation to extract facts and context automatically.
main.py
PYTHONfrom memoair import Message # Add conversation to memoryclient.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 memoriesresults = 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