Everything ChatGPT – under the hood of the ChatGPT web app 3 years ago
they are using Server Side Events (SSE) to stream the text.
see API docs: https://platform.openai.com/docs/api-reference/chat/create
If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. See the OpenAI Cookbook for example code.