Streaming (SSE)

Use Server-Sent Events to stream real-time deliberation progress to your UI.

Overview

When using the hosted API, you can request SSE streaming to receive real-time events as the panel deliberates. This powers the "live deliberation" experience — showing advisor snippets as they form.

Event types

// Server-Sent Events stream

event: deliberation.started
data: { "advisors": ["The Strategist", "The Analyst", ...] }

event: advisor.thinking
data: { "advisor": "The Strategist", "status": "thinking" }

event: advisor.snippet
data: { "advisor": "The Strategist", "snippet": "Looking at the scalability..." }

event: advisor.complete
data: { "advisor": "The Strategist", "response": "..." }

event: synthesis.started
data: {}

event: synthesis.snippet
data: { "snippet": "The panel broadly agrees on..." }

event: deliberation.complete
data: { "memo": { ... } }  // Full DecisionMemo

Client-side consumption

const response = await fetch('/v1/deliberate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer dm_...',
    'Content-Type': 'application/json',
    'Accept': 'text/event-stream',
  },
  body: JSON.stringify({
    question: "Should we adopt GraphQL?",
    stream: true,
  }),
});

const reader = response.body
  .pipeThrough(new TextDecoderStream())
  .getReader();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;

  // Parse SSE events
  for (const line of value.split('\n')) {
    if (line.startsWith('data: ')) {
      const data = JSON.parse(line.slice(6));
      // Update your UI
    }
  }
}
Tip
The deliberation typically takes 15-30 seconds. Use the advisor.snippet events to show real-time progress — this makes the wait feel purposeful rather than empty.

Non-streaming mode

If you don't need streaming, omit the stream: true parameter. The API will return the complete Decision Memo as a single JSON response once deliberation finishes.