Stream Verdict

GET /v1/verdicts/:id/stream — Stream debate events in real-time via Server-Sent Events (SSE).

1 min read
Share
GET/v1/verdicts/:id/stream

Stream debate events in real-time via Server-Sent Events.

Path Parameters

NameTypeRequiredDescription
idstringRequiredThe debate ID to stream.

Example Request

bash
curl -N https://api.askverdict.ai/v1/verdicts/dbt_abc123/stream \
  -H "Authorization: Bearer vrd_your_api_key"

SSE Event Format

Events follow the standard SSE format:

plaintext
event: argument
data: {"agent":"pro","round":1,"content":"MongoDB offers flexible schema..."}
 
event: argument
data: {"agent":"con","round":1,"content":"PostgreSQL's ACID compliance..."}
 
event: verdict
data: {"recommendation":"Stay with PostgreSQL","confidence":82}
 
event: debate.completed
data: {"debateId":"dbt_abc123","status":"completed"}

Event Types

EventDescriptionData Fields
debate.startedDebate processing has begundebateId, mode
argumentAn agent made an argumentagent, round, content
rebuttalAn agent rebuttedagent, round, content, targetAgent
verdictFinal verdict deliveredrecommendation, oneLiner, confidence, reasoning
debate.completedDebate finished successfullydebateId, status
debate.failedDebate encountered an errordebateId, error

Client Examples

TypeScript (SDK)

typescript
import { AskVerdictClient } from "@askverdict/sdk";
 
const client = new AskVerdictClient({ apiKey: "vrd_..." });
const stream = client.streamVerdict("dbt_abc123");
 
for await (const event of stream) {
  switch (event.type) {
    case "argument":
      console.log(`[${event.agent}] ${event.content}`);
      break;
    case "verdict":
      console.log(`Verdict: ${event.recommendation} (${event.confidence}%)`);
      break;
    case "debate.completed":
      console.log("Done!");
      break;
  }
}

JavaScript (Browser)

javascript
const eventSource = new EventSource(
  "https://api.askverdict.ai/v1/verdicts/dbt_abc123/stream",
  { headers: { Authorization: "Bearer vrd_..." } }
);
 
eventSource.addEventListener("argument", (e) => {
  const data = JSON.parse(e.data);
  console.log(`[${data.agent}] ${data.content}`);
});
 
eventSource.addEventListener("verdict", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Verdict: ${data.recommendation}`);
  eventSource.close();
});

Reconnection

If the connection drops, the client should reconnect. The stream replays events from the beginning if the debate is still running. If the debate is already completed, it returns the final state immediately.

The SDK handles reconnection automatically. For raw SSE, implement exponential backoff starting at 1 second.

Was this page helpful?