Streaming
A large input takes time to scan, and a connection that sends nothing for too long is cut by the networks on
the way. Ask /v1/scan for server-sent events and the connection carries progress until the verdict is
ready.
Asking for a stream
Section titled “Asking for a stream”Any of:
"stream": truein a JSON body;?stream=truein the query string;- an
Acceptheader that preferstext/event-streamto JSON (*/*counts as JSON).
"stream": false always answers JSON. Chat completions stream in
their own format.
Events
Section titled “Events”event: progressdata: {"id":"scan-…","scanned_bytes":262144,"total_bytes":157286400,"segments_done":1,"segments_total":620}
event: resultdata: { …the scan object a non-streaming call returns… }| Event | When | Data |
|---|---|---|
progress |
As the scan advances | id, scanned_bytes, total_bytes, segments_done, segments_total. Says how far the scan has got, nothing about the verdict. |
result |
Once, at the end | The scan object. |
error |
Once, instead of result |
The error object. There is never a result after it. |
A comment line is sent every 15 seconds to keep the connection open.
A request that is refused before the scan starts (a bad key, a malformed or oversized body, rate limits) gets a plain HTTP error, even when it asked for a stream.
Cancelling
Section titled “Cancelling”Closing the connection cancels the scan.