Relaying a stream, not waiting for a completion
POST /chats/{chat_id}/reply/stream returns Server-Sent Events built with axum::response::sse and async-stream. Upstream, OpenAI's own SSE response is read through bytes_stream() and eventsource-stream, so each token is forwarded as a typed delta, error or done event.
Malformed chunks, role-only chunks and empty deltas are skipped by a small extract_delta parser with its own unit tests. When the client stops generating, the dropped connection ends the stream future on the server, and whatever text already arrived is persisted as the assistant message instead of being discarded.












