Client
The MemoAir client is your entry point to all SDK functionality. It provides both synchronous and asynchronous interfaces.
Installation
pip install memoairQuick Start
1from memoair import MemoAir23# Initialize with API key4client = MemoAir(api_key="memoair_sk_...")56# Or use environment variable (recommended)7# export MEMOAIR_API_KEY="memoair_sk_..."8client = MemoAir()910# Access resources11client.memories # Episodic memory operations12client.search # Semantic search13client.facts # Explicit facts/triplets14client.documents # Document ingestion15client.ontology # Schema management16client.agent # Conversational agentMemoAir()Initialize a new MemoAir client instance.
Parameters
api_keystr | NoneOptionalDefault: NoneYour MemoAir API key. Falls back to the MEMOAIR_API_KEY environment variable if not provided.
base_urlstr | NoneOptionalDefault: NoneBase URL for the MemoAir API. Falls back to MEMOAIR_BASE_URL environment variable.
graph_urlstr | NoneOptionalDefault: NoneURL for the graph service. Falls back to MEMOAIR_GRAPH_URL environment variable.
timeoutfloatOptionalDefault: 30.0Request timeout in seconds.
max_retriesintOptionalDefault: 3Maximum number of retry attempts for failed requests.
on_requestCallable[[httpx.Request], None] | NoneOptionalDefault: NoneOptional callback function called before each request.
on_responseCallable[[httpx.Response], None] | NoneOptionalDefault: NoneOptional callback function called after each response.
Async Client
For async applications, use AsyncMemoAir with the same interface:
1from memoair import AsyncMemoAir2import asyncio34async def main():5 async with AsyncMemoAir(api_key="memoair_sk_...") as client:6 # All methods are async7 await client.memories.add(8 group_id="user:123",9 messages=[...]10 )1112 results = await client.search.tripartite(13 query="What do I know about the user?",14 user_id="user:123"15 )1617asyncio.run(main())Context Manager
Both clients support context managers for automatic resource cleanup:
1# Sync2with MemoAir() as client:3 client.memories.add(...)45# Async6async with AsyncMemoAir() as client:7 await client.memories.add(...)Available Resources
client.memoriesAdd and retrieve episodic memory from conversations.
client.searchSemantic search across knowledge graphs.
client.factsCreate and manage explicit facts/triplets.
client.documentsUpload and process documents.
client.ontologyLoad and manage domain schemas.
client.agentConversational agent with tool use.