@tzolov, I took a close look at the code and ran the beanStreamOutputParserRecords test in OpenAIClientIT. I'm sorry for the delayed response; I ran into an issue and needed some time to address it.

I made some changes, including defining the Delta for ChatCompletionChunk within the class to handle OpenAI's SSE for ChatCompletionChunk objects. I also adjusted the ObjectMapper for generating response JSON to align with the one used in RestClient.

Additionally, I refactored the code related to ending the Flux Stream and put it into a separate commit.

Please check out the draft pull request, and feel free to reach out if you have any questions or need further clarification.

Comment From: tzolov

Rebased, squashed and merged at b54bb8bc8a56a3a9e6fc5241b87c433fbadf25fc