Quickstart
You’ll need a Beru account (sign up, from $9 a month)
and a terminal. Every example uses the production API, https://api.beru.airesearchlabs.si.
-
Create an API key. In the console, open your project → API keys → Create key. Copy the key: it’s shown once. Keep it on your server, never in a browser or app.
Terminal window export BERU_API_KEY="beru_sk_…" -
Upload a document. PDF, DOCX, TXT, Markdown, HTML, or a PNG, JPG or WebP image of a document (scans and photos are read for you), up to 50 MB.
Terminal window curl https://api.beru.airesearchlabs.si/v1/documents \-H "Authorization: Bearer $BERU_API_KEY" \-F file=@handbook.pdfTerminal window pip install beru-aifrom beru import Beruberu = Beru() # reads BERU_API_KEYwith open("handbook.pdf", "rb") as f:document = beru.documents.upload(f, filename="handbook.pdf")Terminal window npm install beru-aiimport { Beru } from "beru-ai";import { readFile } from "node:fs/promises";const beru = new Beru(); // reads BERU_API_KEYconst document = await beru.documents.upload({file: new Blob([await readFile("handbook.pdf")]),filename: "handbook.pdf",});Beru answers
202with the document and"status": "queued". Processing runs in the background and usually takes a few seconds. -
Wait until it’s ready. Poll the document with the
idfrom the upload:Terminal window curl https://api.beru.airesearchlabs.si/v1/documents/DOCUMENT_ID \-H "Authorization: Bearer $BERU_API_KEY"When
statusisready, it can be searched. If it’sfailed,errorsays why in plain English. -
Ask a question.
Terminal window curl https://api.beru.airesearchlabs.si/v1/answer \-H "Authorization: Bearer $BERU_API_KEY" \-H "Content-Type: application/json" \-d '{"query": "How many days of annual leave do I get?"}'beru.documents.wait_until_ready(document["id"])answer = beru.answer("How many days of annual leave do I get?")print(answer["answer"])for c in answer["citations"]:print(c["number"], c["document_title"], c["page_from"])await beru.documents.waitUntilReady(document.id);const answer = await beru.answer({ query: "How many days of annual leave do I get?" });console.log(answer.answer);for (const c of answer.citations) console.log(c.number, c.document_title, c.page_from); -
Read the citations. The answer cites its sources as
[1],[2]… and each number is incitations:{"answer": "Full-time staff get 25 days of annual leave plus bank holidays [1].","citations": [{"number": 1,"document_title": "handbook.pdf","page_from": 12,"page_to": 12,"document_id": "…","chunk_id": "…"}],"answered": true,"source": "generated","query_log_id": "…"}If no document supports an answer,
answeredisfalseand Beru says it doesn’t know, instead of guessing. Those questions appear under Unanswered in the console.
- Stream the answer as it’s written: add
"stream": true(Server-Sent Events:deltaevents, then onedoneevent with the object above). - Answer for one of your users with their private documents and memories: Per-user memory.
- Generate answers with your own model: Use your own model.
- Every endpoint: API reference. Both SDKs: Python and TypeScript SDKs.
Stuck? Email support@airesearchlabs.si.