Skip to content

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.

Any of:

  • "stream": true in a JSON body;
  • ?stream=true in the query string;
  • an Accept header that prefers text/event-stream to JSON (*/* counts as JSON).

"stream": false always answers JSON. Chat completions stream in their own format.

event: progress
data: {"id":"scan-…","scanned_bytes":262144,"total_bytes":157286400,"segments_done":1,"segments_total":620}
event: result
data: { …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.

Closing the connection cancels the scan.