Skip to content

Python and TypeScript SDKs

Both SDKs are thin, typed clients over the API. They use the API’s own field names (end_user_id, conversation_id) and read your key from BERU_API_KEY.

Terminal window
pip install beru-ai # Python 3.11+, imported as `beru`
from beru import Beru
beru = Beru()
with open("handbook.pdf", "rb") as f:
document = beru.documents.upload(f, filename="handbook.pdf")
beru.documents.wait_until_ready(document["id"])
answer = beru.answer("Is parking free?", end_user_id="user_123")
follow_up = beru.answer(
"And on Saturdays?",
end_user_id="user_123",
conversation_id=answer["conversation_id"],
)
for event in beru.answer_stream("What are your opening hours?"):
if event.type == "delta":
print(event.text, end="", flush=True)

AsyncBeru has the same methods, awaited.

Python TypeScript API
documents.upload, add_url, list, get, delete, wait_until_ready documents.upload, addUrl, list, get, delete, waitUntilReady /v1/documents
answer, answer_stream, retrieve, feedback answer, answerStream, retrieve, feedback /v1/answer, /v1/retrieve, /v1/feedback
memories.add, extract, list, delete memories.add, extract, list, delete /v1/memories
end_users.erase endUsers.erase /v1/end-users/{id}
usage usage /v1/usage

Every failure is a BeruError with code (as in Limits and errors), status, message and the request id. Rate limits (429) are retried, honouring Retry-After; reads, deletes and uploads are also retried after timeouts and brief outages. Uploads carry an Idempotency-Key, so a retry never uploads twice. Turn retries off with max_retries=0 (Python) or maxRetries: 0 (TypeScript).

Packages: PyPI · npm