⌘K
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/streamStream debate events in real-time via Server-Sent Events.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The 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
| Event | Description | Data Fields |
|---|---|---|
debate.started | Debate processing has begun | debateId, mode |
argument | An agent made an argument | agent, round, content |
rebuttal | An agent rebutted | agent, round, content, targetAgent |
verdict | Final verdict delivered | recommendation, oneLiner, confidence, reasoning |
debate.completed | Debate finished successfully | debateId, status |
debate.failed | Debate encountered an error | debateId, 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?