stream Chat Completion
@Contract(pure = true )
Calls the chat completions API endpoint and streams each token 1 at a time for a faster response.
This method is technically not blocking, but the returned iterable will block until the next token is generated.
// Each iteration of the loop will block until the next token is streamed
for (chunk in openAI.streamChatCompletion(request)) {
// Do something with the chunk
}
Content copied to clipboard
Return
The response from the API
Parameters
request
The request to send to the API