How to Resolve Error Code 500 in BatchAPI Requests

Hi,
Is there anyone facing error:
InternalServerError: Error code: 500 - {'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 req_bfac4dc012a38ac4a5aa7c71605b9c43 in your email.)', 'type': 'server_error', 'param': None, 'code': None}}

Here is my code:
client.files.create(
file=open(“upload_file.jsonl”, “rb”),
purpose=“batch”
)

client.batches.create(
input_file_id=“file_id”,
endpoint=“/v1/chat/completions”,
completion_window=“24h”
)

My data format is:
{“custom_id”: “request-1”, “method”: “POST”, “url”: “/v1/chat/completions”,
“body”: {“model”: “gpt-4-turbo-2024-04-09”,
“messages”: [{“role”: “system”, “content”: “instruction”},
{“role”: “user”, “content”: “input”}]}}
{“custom_id”: “request-2”, …}

Welcome to the Forum!

Given it’s a server error, I would recommend trying again in a litte bit and see if the issue persists.

The code snippets look fine in principle. The one thing I’d point out is that your batch data should be formatted as a JSONL file, meaning every request in the batch needs to be in a single line. Currently it looks like you have line breaks - that said, perhaps this is just due to the pasting here in the message?!

Hi there,
Thanks for your replying! I tried for several times, but this issue does still persist. Also, my file format is jsonl file, with each request for a line.

Hm. I just tested again on my end and faced no issue.

image

I’ve encountered the same issue as described. I tried to use the BatchAPI to create KnowledgeGraph Triplets and uploaded several jsonl files. Unfortunately, each time I attempted to create the Batch Job, I received the same error:

InternalServerError: Error code: 500 - {'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 req_e3a3dde5f6228c7f92a63f372361f4b8 in your email.)', 'type': 'server_error', 'param': None, 'code': None}}

I tried both yesterday and today, several times, but the problem persists without any change.

Additionally, there seems to be a problem with file management on the platform as well. I am unable to delete the jsonl files I uploaded; trying to do so results in another error:

"There was an error deleting the file: No such File object: file-XXX"

Has anyone else faced these issues recently? Any advice on how to proceed or get around these problems would be greatly appreciated.

Hi ,
I tried for several days, but this issue does still persist. I double checked my jsonl file. I also tried doc example request.
I tried curl, python, node api but this issue does still persist.

I’ve been dealing with this all week as well - initially only happened when I reuploaded the same file but now it’s happening on 80+% of all requests. It’s been a week since I contacted OpenAI support and have gotten no response. Anybody who figures this out please let us know here!

1 Like

I got it today at random in one of my batch files (which have all been fine)

{"id": "batch_req_66f34bde...", "custom_id": "batch_cs_0_0", "response": {"status_code": 500, "request_id": "", "body": {}}, "error": null}
{"id": "batch_req_66f34bde...", "custom_id": "batch_cs_0_1", "response": {"status_code": 500, "request_id": "", "body": {}}, "error": null}

with "error": null