Subscribe to a lens session’s Server-Sent Events stream to receive asynchronous inference results
Documentation Index
Fetch the complete documentation index at: https://docs.archetypeai.app/llms.txt
Use this file to discover all available pages before exploring further.
server_sent_events_writer (used by the Activity Monitor lens and most cookbook lenses) write inference results, log messages, and stream status events to this channel.
model_pipeline includes a server_sent_events_writer output processor.session.read.session.read returns event_data: null while GET /lens/sessions/metadata shows non-zero num_outputs, the lens is writing to the SSE consumer — use this endpoint.The official archetypeai Python SDK exposes this endpoint as lens.create_sse_consumer(session_id).Bearer YOUR_API_KEYtext/event-stream (recommended — signals SSE intent to the server and to intermediaries)id, so reconnecting clients do not miss or duplicate messages. Matches the standard SSE reconnection semantic.text/event-stream HTTP response. Each frame is a standard SSE record:
data: payload is JSON and always includes a type field identifying the event. The consumer emits three envelope event types in addition to lens-specific output events:
session_id of the stream and a server-assigned reader_id that identifies this consumer connection.message_timeout increments with each heartbeat — clients should ignore the payload contents but can use the frame as a liveness signal.type values are lens-specific output events. Typical types emitted by server_sent_events_writer include inference.result, log.info, frame.processed, and error. The exact shape of the data payload depends on the lens’s model_pipeline and the processor that produced the event.
session.read| SSE consumer (this endpoint) | session.read | |
|---|---|---|
| Transport | HTTP text/event-stream | WebSocket event over session_endpoint |
| Pattern | Server pushes events as they arrive | Client polls; server returns queued messages |
| Used by | Lenses with server_sent_events_writer output processors | Lenses with mailbox-style output processors |
| Cursor / resume | Last-Event-ID request header | client_id field in event_data |
| Heartbeats | sse.stream.heartbeat envelope events | None (request/response pattern) |
| Graceful close | sse.stream.end envelope event, then HTTP close | Close WebSocket |
model_pipeline via GET /lens/metadata to see which output processor (and therefore which channel) it uses.