Error with api json and http

I tried to send a post request through the macrodroid app with these parameters:
Content type - application/json
Content body - Text
{
“model”: “gpt-3.5-turbo”,
“messages”: test
}
Authorization - Bearer …

and it’s output this:
{
“error”: {
“message”: “We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
Can someone help, please?:pray:

Try sending valid API input. You can consult the API reference on the left bar of the forum.

Content type - application/json
Content body - Text
{
    "model": "gpt-3.5-turbo",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }
Authorization - Bearer …

The multiline container for messages and inclusion within a string will depend on the environment and code you use.

1 Like

i didn’t input anything else, just these

(1)

To replicate the initial request made by my operating Python script I have at hand using your standalone HTTPS request utility, you would need to format the “content body” with JSON data to make a similar request. Here’s how you should structure your JSON input:

{
  "model": "gpt-3.5-turbo",
  "max_tokens": 123,
  "top_p": 0.9,
  "messages": [
    {
      "role": "system",
      "content": "You are ChatAPI"
    },
    {
      "role": "user",
      "content": "Provide brief introduction."
    }
  ]
}

Make sure to set the Content-Type header to application/json and include an Authorization header with your OpenAI API key in the format Bearer YOUR_API_KEY_HERE. This JSON structure and the headers are what you need, in addition to the https request being sent to the correct chat completions URL https://api.openai.com/v1/chat/completions

1 Like