Hi fellows, I am getting this error while testing API for first time, how to fix it ?
There was an issue setting up your call.
Raw response for the API
Status code 400
{
“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 send an email to support@openai.com and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
Missing a closing quote after the prompt, before the comma
Should be “prompt”:"Write three descriptions for the following products:\nProduct names: \nDescription: \nTone: \n.",
And I’m assuming those \n’s are for OpenAI to know there is a linebreak?
didnt work. below is the actual prompt from open AI
'{
"model": "text-davinci-003",
"prompt": "Write three descriptions for the following products:\nProduct names: Pop Prints\nDescription: An app that makes sending printed pictures super easy to friends and family, simply pick a photo, choose a recipient and press send, we take care of printing and mailing. \nTone: Happy \n\n1. Pop Prints is here to make every moment a lasting memory. With just a few clicks, you can easily send printed pictures to your loved ones and make them smile! \n\n2. Sending pictures shouldn't be hard. With Pop Prints, you can easily select a photo, choose your recipient, and press send. We'll take care of the rest! \n\n3. Capture your most precious moments and share them with your loved ones with Pop Prints. It's never been easier to send printed photographs - just pick your photo and press send!",
"temperature": 0.8,
"max_tokens": 200,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}'
double quote made the difference but I get below now .
There was an issue setting up your call.
Raw response for the API
Status code 400
{
“error”: {
“message”: “you must provide a model parameter”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
wohoo, It worked now, looks like i had taken model off and didn’t put back, actual problem was that i had missed the double quote which you had pointed and then off course modle.
Well Happy New Year 2023 Tyler. appreciate that you helping , now i ll complete my first ever app before morning.
hello , thank God i found this thread. running into the same issue and i cant wrap my head around it. can you assist me ? the api call returns the same response
‘{
“model”: “text-davinci-003”,
“prompt”: “##### Fix bugs in the below function\n \n### Buggy Python\nimport Random\na = random.randint(1,12)\nb = random.randint(1,12)\nfor i in range(10):\n question = “What is “+a+” x “+b+”? “\n answer = input(question)\n if answer = a*b\n print (Well done!)\n else:\n print(“No.”)\n \n### Fixed Python”,
“temperature”: 0,
“max_tokens”: 182,
“top_p”: 1,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“stop”: [”###”]
}’
this is the code and it is showing
There was an issue setting up your call.
Raw response for the API
Status code 400
{
“error”: {
“message”: “you must provide a model parameter”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}