Skip to content

Streaming answers

Answers start arriving in about a second. Send "stream": true to get them piece by piece instead of waiting for the whole answer.

Terminal window
curl -N https://api.beru.airesearchlabs.si/v1/answer \
-H "Authorization: Bearer $BERU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "Is parking free?", "stream": true}'

The response is text/event-stream:

event: delta
data: {"text": "Yes, parking is "}
event: delta
data: {"text": "free behind the clinic [1]."}
event: done
data: {"answer": "Yes, parking is free behind the clinic [1].", "citations": [...], "answered": true, ...}
  • delta: the next piece of text. Append them in order.
  • done: the full answer object, the same as without streaming, including citations and conversation_id. Show sources from here.
  • error: something failed after streaming began, with the usual error envelope.

Errors before the first piece, such as an invalid key or a plan limit, are normal HTTP errors, not events.

  • Citation markers like [1] can arrive split across pieces. Render them once done arrives, or after each piece on the text so far.
  • A question is counted when it starts. If the reader disconnects mid-answer, it still counts.
  • Behind a proxy, turn off response buffering for this route so pieces aren’t held back.