How to use this Streaming API with a JSON Object

I’m using the OpenAI Streaming API with assistants, but I’m facing an issue where the stream returns a broken or incomplete JSON object. I’ve tried several methods to fix the JSON after receiving it (such as adding closing braces and fixing strings), but I can’t seem to get a valid, fully-formed JSON object as the stream progresses.

Is there any way to configure the API to return a well-formed JSON structure that populates incrementally?

Thanks in advance for any suggestions!

Hi @markguy9 and welcome to the community!

You may want to have a look at this post, since it deals with resolving valid JSON when streaming.

1 Like