FastAPI · Class
EventSourceResponse
EventSourceResponse streams values yielded by a FastAPI path operation as Server-Sent Events. Use ServerSentEvent to control event fields such as id, event, retry, comment, or raw text.
Last updated
Syntax
@app.get("/stream", response_class=EventSourceResponse)
async def stream() -> AsyncIterable[ServerSentEvent]:
yield ServerSentEvent(data=value)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
ServerSentEventfastapi.sseLast-Event-IDEventSourceResponseStream Data