Skip to content

Metadata and filters

Attach your own labels when you upload, then pass filters to search only documents whose labels match.

metadata is a JSON object of your choice, sent as a form field with the file:

Terminal window
curl https://api.beru.airesearchlabs.si/v1/documents \
-H "Authorization: Bearer $BERU_API_KEY" \
-F file=@leeds-opening-hours.pdf \
-F 'metadata={"branch": "leeds", "language": "en"}'

In Python: beru.documents.upload(f, filename="…", metadata={"branch": "leeds"}). In TypeScript: metadata: { branch: "leeds" }.

Terminal window
curl https://api.beru.airesearchlabs.si/v1/answer \
-H "Authorization: Bearer $BERU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "What time do you close on Saturday?", "filters": {"branch": "leeds"}}'

A document matches when its metadata contains every key/value in filters. With {"branch": "leeds"}, a document labelled {"branch": "leeds", "language": "en"} matches; one labelled {"branch": "york"} or with no labels doesn’t. filters works the same on /v1/retrieve.

  • Branches or locations: one project for a chain, filtered by the branch the person picked.
  • Product lines or plans: answer only from the documentation for what the customer owns.
  • Audiences: keep staff-only procedures out of customer answers with {"audience": "customer"}.

Filters narrow shared documents; private documents still follow their end user. For strict separation between different businesses, use separate projects, each with its own API keys.