Streaming Integration (SSE)
SetresponseMode: "stream" to receive progressive compliance results as each agent finishes. The connection stays open until the run completes; events arrive as soon as each phase produces output. Useful when you want to show live progress in a UI rather than waiting 60–240 seconds for a single sync response.
Endpoint
Content-Type: text/event-stream. Time-to-first-event is typically under 1 second.
Event sequence
A successful run produces this sequence (events are SSE format:event: <type>\ndata: <json>\n\n):
complete (success) or error (failure). After a terminal event the server closes the connection.
Event types
| Event | When | Payload |
|---|---|---|
job.started | Once, immediately after headers flush | { timestamp } |
agent.started | Once per agent, when the agent begins work | { agentId, timestamp } |
agent.completed | Once per agent, when the agent’s promise resolves | { agentId, checks: [], timestamp } |
score.computed | After Stage D finishes scoring | { score, decision, timestamp } |
complete | Terminal success | { data: { score, decision, checks, checksById, indexes, annotations, profile, agentSummaries, versionInfo, creditsCharged, cached, costBreakdown }, timestamp } |
error | Terminal failure | { message, code, timestamp } |
agentId is one of: ai-laws, advertising-law, rights-clearance, rights-clearance-image, metadata-labeling, platform-policy.
Client implementation
EventSource (browser)
curl
For quick testing:-N flag disables curl’s output buffering so you see events arrive progressively.
Concurrent stream limit
A maximum of 5 concurrent streams per tenant is enforced. Requests over the cap return429 with a message advising retry. The cap exists to prevent runaway clients from holding open many connections at once. If you legitimately need higher concurrency, contact support.
When to use streaming vs. async
Streaming holds a connection open for the entire run (typically 60–240 seconds depending onmode and scope). Choose:
- Streaming when you want to render live progress in a UI and the client can keep a connection open.
- Async + webhook (guide) when the client can’t or shouldn’t hold a connection open — server-to-server pipelines, mobile apps, or batch workflows.
- Sync (the default) when the run is short enough that progress events aren’t worth the complexity.
Error handling
A pipeline failure delivers a singleerror event then closes:
responseMode: "async" from the start so the result lands in your webhook and persists in the polling endpoint.
Limitations
- No resume from a specific event. There is no
resumeFrom=advertising-lawquery parameter. If the connection drops, re-issue the request (idempotency keys deduplicate). - No partial fallback. If the orchestrator fails mid-run, the server emits one
errorevent with the failure reason — partial check results are not returned. - Multipart requests stay sync. The
multipart/form-dataupload path does not supportresponseMode: "stream". Pass image URLs in the JSON body if you need streaming with image inputs.