constella-sdk is not on PyPI yet. Until it is, call the HTTP routes (the client below is about 15 lines), or email us for the package.import os
from constella_sdk import Constella
# Your own memory
constella = Constella(key=os.environ["CONSTELLA_API_KEY"], client="my-script")
constella.me.memory.add("We ship on Fridays.", id="team:ship-day")
constella.me.memory.recall("when do we ship?")
# Your app's users
app = Constella(key=os.environ["CONSTELLA_APP_KEY"])
app.users("u_123").memory.add("Prefers short answers.")
Without the SDK
import os
from urllib.parse import quote
import requests
API = "https://api.constella.app/platform/v1"
def call_tool(name: str, arguments: dict, uid: str | None = None):
path = f"/users/{quote(uid, safe='')}/tools/{name}" if uid else f"/me/tools/{name}"
key = os.environ["CONSTELLA_APP_KEY" if uid else "CONSTELLA_API_KEY"]
r = requests.post(API + path, headers={"Authorization": f"Bearer {key}"}, json={"arguments": arguments})
if not r.ok:
detail = r.json().get("detail", {})
raise RuntimeError(f"{detail.get('code')}: {detail.get('message')}")
return r.json()["result"]