OpenAI - Error 400 Unrecognized request argument supplied: messages

Hi! I’m trying to use the OpenAI API but keep getting this error message:

There was an issue setting up your call.

Raw response for the API
Status code 400
“error”: {
“message”: “Unrecognized request argument supplied: messages”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null

The body of the API I have is

“model”: “gpt-3.5-turbo”,
“temperature”: 0.2,
“max_tokens”: 1000,
“messages”: [
“role”: “system”,
“content”: “You are a helpful assistant.”
“role”: “user”,

What could be the issue? I have Content-Type and Authorization as headers.

Hi @offdutyventures,

Have you checked out these docs from AirDev about OpenAI?

Make sure your <prompt> is formatted json safe. If there are line breaks that aren’t json safe you’ll get this error (for instance users submitting two paragraphs separated by a space- that won’t work unless you format as json safe. If you’re combining multiple strings of json safe data, I’ve found that doing a find/replace to remove the individual “” and then wrapping the whole appended string in “” works well

It currently is just “Hello!” as seen in the value above?

I’ve done now. Looks a little different but I got mine from OpenAI API documentation so it should be the latest version? Not sure what is wrong with it.

This topic was automatically closed after 70 days. New replies are no longer allowed.