openai-node
openai-node copied to clipboard
Cannot stream chat completions from Azure
Confirm this is a Node library issue and not an underlying OpenAI API issue
- [X] This is an issue with the Node library
Describe the bug
When streaming chat completions using client.chat.completions.create
with AzureOpenAI
client and reading with ChatCompletionStreamingRunner.fromReadableStream
on the client, the following error occurs:
OpenAIError: Cannot read properties of undefined (reading 'content')
Cause:
The error seems to be caused by choice.delta
being undefined at some point during the streaming process, usually at the end of the stream.
Questions:
- Is this a known issue?
- Will this library support streaming from Azure, given potential differences in response structure?
To Reproduce
- Initialize an
AzureOpenAI
client - Using
client.chat.completions.create
stream a response to the client (a web app) - Stream the response using
ChatCompletionStreamingRunner.fromReadableStream
on the client - Observe the error
Code snippets
No response
OS
macOS
Node version
Node v20.14.0
Library version
openai 4.56.0