Home/Documentation

Client

The MemoAir client is your entry point to all SDK functionality. It provides both synchronous and asynchronous interfaces.

Installation

pip install memoair

Quick Start

quickstart.pypython
1from memoair import MemoAir
2
3# Initialize with API key
4client = MemoAir(api_key="memoair_sk_...")
5
6# Or use environment variable (recommended)
7# export MEMOAIR_API_KEY="memoair_sk_..."
8client = MemoAir()
9
10# Access resources
11client.memories # Episodic memory operations
12client.search # Semantic search
13client.facts # Explicit facts/triplets
14client.documents # Document ingestion
15client.ontology # Schema management
16client.agent # Conversational agent
POSTMemoAir()

Initialize a new MemoAir client instance.

Parameters

api_keystr | NoneOptionalDefault: None

Your MemoAir API key. Falls back to the MEMOAIR_API_KEY environment variable if not provided.

base_urlstr | NoneOptionalDefault: None

Base URL for the MemoAir API. Falls back to MEMOAIR_BASE_URL environment variable.

graph_urlstr | NoneOptionalDefault: None

URL for the graph service. Falls back to MEMOAIR_GRAPH_URL environment variable.

timeoutfloatOptionalDefault: 30.0

Request timeout in seconds.

max_retriesintOptionalDefault: 3

Maximum number of retry attempts for failed requests.

on_requestCallable[[httpx.Request], None] | NoneOptionalDefault: None

Optional callback function called before each request.

on_responseCallable[[httpx.Response], None] | NoneOptionalDefault: None

Optional callback function called after each response.

Async Client

For async applications, use AsyncMemoAir with the same interface:

async_example.pypython
1from memoair import AsyncMemoAir
2import asyncio
3
4async def main():
5 async with AsyncMemoAir(api_key="memoair_sk_...") as client:
6 # All methods are async
7 await client.memories.add(
8 group_id="user:123",
9 messages=[...]
10 )
11
12 results = await client.search.tripartite(
13 query="What do I know about the user?",
14 user_id="user:123"
15 )
16
17asyncio.run(main())

Context Manager

Both clients support context managers for automatic resource cleanup:

1# Sync
2with MemoAir() as client:
3 client.memories.add(...)
4
5# Async
6async with AsyncMemoAir() as client:
7 await client.memories.add(...)

Available Resources

client.memories

Add and retrieve episodic memory from conversations.

client.search

Semantic search across knowledge graphs.

client.facts

Create and manage explicit facts/triplets.

client.documents

Upload and process documents.

client.ontology

Load and manage domain schemas.

client.agent

Conversational agent with tool use.