Keep getting an error message that says 'We could not parse the JSON body of your request.'

I simply thought I had made a mistake in my code. I was trying to translate an Excel file containing natural language texts using ChatGPT and then output it back to an Excel file. However, the same error kept occurring.

Reducing the number of rows in the Excel file seemed to solve the problem, but now the same issue is happening again.

How can I fix this?

Here is the code I am using to make the API request:

for sentence in sentences:
        completion = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {"role": "system", "content": "I'll present you with a sentence. \
            Analyze the emotion of the sentence and respond with one of the following: \
            'positive,' 'negative,' or 'neutral.' Respond with only one of these words, and do not add any other words."},
            {"role": "user", "content": sentence}  
        ]
        )

Welcome to the dev community!

‘We could not parse the JSON body of your request.’

Sounds like you’re sending too many tokens… Is that the API error code you’re getting?

The API reference docs have a good list of most error codes you’ll get back…

https://platform.openai.com/docs/guides/error-codes/api-errors

Just to be sure, you’re talking about the API and not ChatGPT, correct?

Yeah right.
I got it from API call.