Streaming output is used for the Chat and Responses interfaces. It returns content chunk by chunk, providing a better user experience (no need to wait until the entire content is generated before showing it).
If you don't use the SDK and parse the SSE stream yourself, pay attention to the following:
1.
Read line by line: Each data item occupies one line, starting with data:
2.
Skip empty lines: Empty lines are event delimiters in the SSE protocol and do not affect the data
3.
Detect end: Stop reading when you encounter data: [DONE]
4.
Handle disconnections: You can retry after a network interruption, but you cannot resume from the breakpoint. You'll need to initiate the request again
5.
Timeout settings: We recommend setting the HTTP client timeout to 60 seconds or more, as long text generation may take a while