Stream AI model responses in real-time using Server-Sent Events. Tokens are delivered as they are generated.
"auto" for random selectionSelection Logic (Lines 468-470):thread_messages tabletext/event-stream (Line 450)
Headers (implicit in ASP.NET SSE):
INVALID_REQUEST: Prompt validation failed (Line 459)STREAM_ERROR: Provider or network error (Line 515)message_logs table write not enforced by server contract (implementation detail)
data: {json}\n\n (Line 495)StreamAsync methodthread_messages table
Reason: Partial streams cannot be meaningfully stored
Workaround: Use non-streaming /api/arena/chat if persistence required
UTF-8 Encoding: All events UTF-8 encoded (Line 464 decoder implicit)
Single-Line JSON: Event payloads MUST NOT contain newlines (breaks SSE format)
Provider Support: Only providers implementing StreamAsync method support streaming
data: prefix (required)\n\n double newline (event terminator)\n\ndata: object field| Code | Format | Cause | Controller Line |
|---|---|---|---|
INVALID_REQUEST | SSE event | Prompt null/whitespace | 452-463 |
STREAM_ERROR | SSE event | Provider exception | 506-525 |
| N/A | Silent | Client disconnect | 504 (token) |
ai.error events and display to user