Error on tryng to use batches

Hello!

I’m encountering an error when trying to make a request using batches.

The error I get is: OpenAI API Error: Invalid body: failed to parse JSON value. Please check the value to ensure it is valid JSON. (Common errors include trailing commas, missing closing brackets, missing quotation marks, etc.)

The file ID I am attaching to the request is a JSONL with the test structure from the documentation, which is as follows:

{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo-0125", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}
{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo-0125", "messages": [{"role": "system", "content": "You are an unhelpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}

I have also tried sending other data, but I always get the same error.

I’m making the request using curl with the headers and parameters indicated in the documentation.

Has anyone encountered a similar situation?

Thanks!

Hi there!

Couple of points:

  1. Could you share a couple of examples from your batch? This would help to investigate whether there are any errors in the way you’ve set up your JSONL file.

  2. Just to be sure, you are following the two step process for the creation of a batch, right? Meaning, you first upload the JSONL file via file upload request with the purpose batch, then fetch the returned file-ID and thereafter create a batch request with the file-ID.

1 Like

Hi! Thanks for the answer!

The example that i shared in the post is what i uploaded as a file using the file upload request endpoint and then making the batch request using that file id.

It is weird that i’m getting that error because i’m using the example that the documentation provides (were trying using another using the same format)

Regards.

1 Like

The easiest check would just be to paste it into a code editor and see if it throws any error. It’s probably just something minor. Without seeing your data, it’s difficult to identify the issue.

1 Like

I’m having the same problem… Did you find a solution @baezapm?

Do you have more details, @aloisejulian ?

Have you tested your data in a code editor to look for errors?

1 Like