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.
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.
npm install beru-ai # Node 18+, Deno, Bun and edge runtimesimport { Beru } from "beru-ai";import { readFile } from "node:fs/promises";
const beru = new Beru();
const document = await beru.documents.upload({ file: new Blob([await readFile("handbook.pdf")]), filename: "handbook.pdf",});await beru.documents.waitUntilReady(document.id);
const answer = await beru.answer({ query: "Is parking free?", end_user_id: "user_123" });const followUp = await beru.answer({ query: "And on Saturdays?", end_user_id: "user_123", conversation_id: answer.conversation_id ?? undefined,});
for await (const event of beru.answerStream({ query: "What are your opening hours?" })) { if (event.type === "delta") process.stdout.write(event.text);}Keep your API key on a server, never in a browser or mobile app.
What’s included
Section titled “What’s included”| 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 |
Errors and retries
Section titled “Errors and retries”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).