Python SDK
The official Suprflo SDK for Python. Wraps the REST API.
Install
bash
pip install suprflo
# with the LangChain integration:
pip install "suprflo[langchain]"Quickstart
python
from suprflo import MemoryClient # MemoryGClient is an alias
client = MemoryClient(api_key="YOUR_API_KEY") # base_url defaults to https://api.suprflo.com
# Add memories from a message (string, {role, content}, or a list)
client.add("I'm vegetarian and allergic to peanuts", user_id="alice")
# Recall relevant memories
hits = client.search("what can this user eat?", user_id="alice", top_k=5)
for m in hits["results"]:
print(m["memory"], m["score"])Use it as a context manager to close the HTTP connection cleanly:
python
with MemoryClient(api_key="…") as client:
client.add(messages, user_id="alice")Methods
| Method | REST call |
|---|---|
add(messages, *, user_id=…, agent_id=…, run_id=…, app_id=…, metadata=…, infer=True, async_mode=False, timestamp=…) | POST /api/memories |
search(query, *, top_k=10, filters=…, threshold=…, rerank=…, memory_types=…, as_of=…, user_id=…) | POST /api/memories/search |
get_all(*, user_id=…, agent_id=…, run_id=…, app_id=…, limit=100, offset=0, memory_types=…) | GET /api/memories |
get(memory_id) | GET /api/memories/{id} |
update(memory_id, data) | PUT /api/memories/{id} |
delete(memory_id) | DELETE /api/memories/{id} |
delete_all(*, user_id=…, …) | DELETE /api/memories |
history(memory_id) | GET /api/memories/{id}/history |
users() | GET /api/memories/users |
Errors
Non-2xx responses raise APIError(status_code, message) (subclass of SuprfloError), with message taken from the API's detail. 503 is a retryable "upstream busy" signal.
Full source: the suprflo package on GitHub.