POST /api/arena/chat/stream takes the same body as Chat and streams the reply as Server-Sent Events. Use it when you want text on screen as soon as the model starts writing.
The event stream
Each event is onedata: line holding a JSON object, followed by a blank line.
The stream endpoint answers with one model and doesn’t save the turn to a thread. For battles, or to keep history, use Start a battle or Chat with a
threadId.Read the stream
The endpoint is aPOST, so use fetch (or your HTTP client’s streaming mode) rather than the browser’s EventSource.
Tips
Cancel early
Abort the request (for example with an
AbortController) to stop generation. The server stops when the connection closes.Errors arrive in-band
Once streaming starts the status is already
200, so failures come as an ai.error event. Always handle it.Render Markdown at the end
Chunks can split Markdown and code fences. Show raw text while streaming and render Markdown once
ai.stream.done arrives.Pick a model
model takes a modelName, a modelId or auto (a random Groq or Google AI Studio model).