openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

audio.speech.create Typescript types are incorrect when `stream: true`

Open omonk opened this issue 10 months ago • 2 comments

Looking at the type here, when passing stream true to the options the response type is still Response

https://github.com/openai/openai-node/blob/a1a125349ba9c9c2bb602c8c8f368e086c41ac1e/src/resources/audio/speech.ts#L11

Image

Comparing this to the chat completions with the stream: true option:

https://github.com/openai/openai-node/blob/a1a125349ba9c9c2bb602c8c8f368e086c41ac1e/src/resources/chat/completions/completions.ts#L35-L38

Image

omonk avatar Feb 26 '25 12:02 omonk

The stream param in the chat completions API is referring to enabling SSE streaming. As far as I am aware the speech API does not support SSE, so the stream request option won't do anything.

Why are you trying to enable streaming? The Response we return shouldn't have been eagerly read fwiw.

RobertCraigie avatar Feb 26 '25 12:02 RobertCraigie

The Response we return shouldn't have been eagerly read fwiw.

Could you expand on this a bit more? I'm not sure I fully understand it.

Regarding the speech streaming, I am attempting to use the chunk transfer encoding response to stream the audio to a browser client - https://platform.openai.com/docs/guides/text-to-speech#streaming-realtime-audio

omonk avatar Feb 26 '25 12:02 omonk