#ChatGPT Streaming API Always return a last Error Chunk

2 messages · Page 1 of 1 (latest)

thick flicker
#

Hi, i am trying to use streaming with the new chat completion api. I'm sending it with these params:

{
"max_tokens": 200,
"temperature": 0.75,
"n": 4,
"stream": true,
"user": "testing",
"messages": [
{
"role": "system",
"content": "You are a masterful fiction writer that will continue the story in a compelling way"
},
{
"role": "user",
"content": "She powers on the microscopic chip embedded in the Wernicke’s area behind her ear lobes, that tiny sliver of brain responsible for speech processing. She subvocalizes her password. The chip captures the minute electrical signals sent to the larynx and emits her ID to the door. The door snicks open and the Voice utters a platitude she ignores."
}
],
"model": "gpt-3.5-turbo-0301"
}

And it does stream correctly, however, the last chunk is always giving me an error field like this:

data: {“error”:{“message”:“The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our help center at help.openai.com if you keep seeing this error. (Please include the request ID fb94b183e8b7bc5aca22fa62981cc107 in your email.)”,“type”:“server_error”,“param”:null,“code”:null}}

This seems to happen regardless of content.

Is this a known issue? Am I doing something wrong?

pearl relic
#

In the short term you could put the call in a try catch block and ignore it. It's not ideal but would let you keep working