Client
The MemoAir client is your entry point to all SDK functionality. It provides both synchronous and asynchronous interfaces.
Installation
pip install memoairQuick Start
from memoair import MemoAir # Initialize with API keyclient = MemoAir(api_key="memoair_sk_...") # Or use environment variable (recommended)# export MEMOAIR_API_KEY="memoair_sk_..."client = MemoAir() # Access resourcesclient.memories # Episodic memory operationsclient.search # Semantic searchclient.facts # Explicit facts/tripletsclient.documents # Document ingestionclient.ontology # Schema managementclient.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:
from memoair import AsyncMemoAirimport asyncio async def main(): async with AsyncMemoAir(api_key="memoair_sk_...") as client: # All methods are async await client.memories.add( group_id="user:123", messages=[...] ) results = await client.search.tripartite( query="What do I know about the user?", user_id="user:123" ) asyncio.run(main())Context Manager
Both clients support context managers for automatic resource cleanup:
# Syncwith MemoAir() as client: client.memories.add(...) # Asyncasync with AsyncMemoAir() as client: 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.