Text generation. Stream output

Hi, I want to use text generation and stream the output similar to ChatGPT. How to do that?