Server error 500 on creating Batch job

I was trying out the new OpenAI batch feature but I keep getting Server Error 500 whenever I try to submit any jobs. At first I thought it might be some issue on OpenAI’s end but after several days I am still getting the same error while others appear to be able to successfully submit jobs so I think maybe it is some issue with my request.

Here is the complete code that I am running on Google Colab:

import json
from openai import OpenAI
from google.colab import userdata
import requests
from tempfile import NamedTemporaryFile

data = [
    {'custom_id': 'request-1', 'method': 'POST', 'url': "/v1/chat/completions", 'body': {'model': 'gpt-3.5-turbo', 'messages': [{'role': 'user', 'content': 'Hello!'}]}},
    {'custom_id': 'request-2', 'method': 'POST', 'url': "/v1/chat/completions", 'body': {'model': 'gpt-3.5-turbo', 'messages': [{'role': 'user', 'content': 'How tall is Mt. Everest?'}]}}]

client = OpenAI(api_key=userdata.get('openai-colab'))

with NamedTemporaryFile(suffix='.jsonl') as f:
    for item in data:
        line = json.dumps(item)+'\n'
        f.write(line.encode('utf-8'))
    file_response = client.files.create(file=f.file, purpose='batch')

batch_response = client.batches.create(
  input_file_id=file_response.id,
  endpoint='/v1/chat/completions',
  completion_window='24h')
batch_response

I get the following 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_a4a007ce711a6a0740ffed8778c47db6 in your email.)', 'type': 'server_error', 'param': None, 'code': None}}

I have tried to do this with a regular jsonl file instead of a TempFile, but the result is the same.

The file is getting uploaded and showing up on the list of files when I run client.files.list() with purpose='batch', status='processed', but the batch job does not get created

client.batches.list()
>>> SyncCursorPage[Batch](data=[], object='list', first_id=None, last_id=None, has_more=False)

I also tried to create the job by sending a POST request from my terminal without using the Python client, but got the same response. Any help would be appreciated. Thank you

2 Likes

I am going through the exact same situation. As suggested, I tried to submit the issue to OpenAI support. Will see if it resolves the issue.

Have you had any progress since you were encountering the issue ?

1 Like