Print message token by token

Hello,

at the moment my tool sends a AJAX request using a PHP file that sends it to https://api.openai.com/v1/chat/completions and generates a JSON message that is rendered via JavaScript.

The problem is that the output is rendered at a strech and not token-via-token.

You could i implement that?

Best regards
Andreas

stream (defaults to false…)

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.

Here you go. Hope your weekend is going well…

1 Like