Flux is a Project Reactor reactive type that emits zero or more data elements asynchronously as they become available. In a Spring AI chat application, returning Flux<String> lets generated response fragments reach the interface progressively instead of waiting for the complete answer. section 3.4.3
Use Flux for streaming responses by:
- Calling ChatClient's stream() method instead of call(). section 3.4.3
- Returning the resulting Flux<String> from the service and controller. section 3.4.3
- Configuring the endpoint for a streamed response rather than application/json. section 3.4.3
Streaming an LLM answer
A board-game service can return generated content through Flux<String>; the client may receive short fragments, often approximately one word at a time, while generation continues. section 3.4.3


