Text streaming refers to the capability of obtaining text responses in segments or parts. With this functionality, the Chat GPT API divides and delivers the response in smaller portions, allowing the user to view the answers without having to wait for the complete conclusion of the request.
Unfortunately, due to certain cache-related factors, not all servers support text streaming functionality. It's worth mentioning that the PHP version does not play a role in this matter. For instance, we have a server that does not support text streaming, as demonstrated here:
http://polargames.com.br/text-stream/
However, we also have another server where text streaming is fully operational.
You can check it out here:
https://polartemplates.com/text-stream/
To ensure that the Chat GPT streaming mode works correctly, the PHP functions ob_flush() and flush() need to be functioning properly. Otherwise, the text output will be displayed all at once.
This occurs because the behavior of ob_flush() and flush() can be affected by different server configurations, as well as factors beyond PHP's control, such as the configuration of the web server itself and any network proxies in use.
Some of the most common reasons for this include:
Web server buffering: Some web servers like Apache and Nginx have their own buffering settings that can interfere with PHP's flush. Check your web server settings to ensure that buffering is disabled or configured correctly.
PHP configuration: The output_buffering directive in the php.ini file can interfere with the behavior of ob_flush() and flush(). Make sure that output_buffering is turned off (set to Off or 0) in the php.ini file.
Compression modules: If you are using output compression with modules like mod_deflate in Apache or gzip in Nginx, this can interfere with data streaming. Disable output compression or configure it properly to allow streaming.
Proxies and CDNs: If your server is behind a proxy or CDN, they may buffer the data before sending it to the client. Check the proxy or CDN settings to ensure that streaming is allowed.
To check if your server supports this function, we offer our users a free test script. With this test, you can try out the text streaming functionality on your server before acquiring our main script.
After accessing the provided link, follow the steps below to test the text streaming functionality on your server:
Download the zip file available at the link: https://polartemplates.com/text-stream/
Unzip the contents of the zip file on your computer.
Upload the extracted files to a folder on your web server.
Access the URL of the folder where the files were uploaded using your web browser.
By following these steps, you will be able to test the text streaming function on your server. If everything is set up correctly and your server supports the functionality, you will see the text streaming working as expected.
Yes, this function is not mandatory. You can use the script without the text streaming feature, the only difference is that the text will not be displayed in chunks but all at once.
In our tests and support, we have found that servers from hostnamecheat and hostinger work perfectly with text streaming, which is why we always recommend these hosts to our clients, without gaining anything from it.