Hello everyone! My first post here.
I’ve created a power automate flow in MS teams to process a query to ChatGPT. I’m getting an Error Code 400 Bad Request with this HTTP. Can anyone explain to me why this is failing? I can’t seem to figure it out. Only a max token of 2000.
Thanks so much and looking forward to your great input!
{
“uri”: “https:slash-slash-api.openai.com/v1/completions”,
“method”: “POST”,
“headers”: {
“Accept”: “application/xml”,
“Content-Type”: “application/json”,
“Authorization”: “sanitized”
},
“body”: {
“model”: “text-davinci-003”,
“prompt”: “chatgpt what is 5+5”,
“max_tokens”: 2000,
“temperature”: 0
}
}
Here’s a request to the replacement for text-davinci-003. From the “get code” of the API playground.
curl https://api.openai.com/v1/completions
-H “Content-Type: application/json”
-H “Authorization: Bearer $OPENAI_API_KEY”
-d ‘{
“model”: “gpt-3.5-turbo-instruct”,
“prompt”: “Hello”,
“temperature”: 0.5,
“max_tokens”: 1024,
“top_p”: 0.5,
}’
“accept” isn’t given as a header. The other implementation details of that container will be specific to the platform.
Remove the “Accept” line from headers.
Authorization should be in the form “Bearer sk-88888888888888” with your API key.
One must have an OpenAI API account, with credits available for payment of services, and generate an API key.
A tool that reported the error message as well as the error code would be useful. Look at the raw output.
removed accept.
I do have account with plenty of tokens.
Still error. Here’s raw:
{
“curi”: “https:sl-sl-api.openai.com/v1/completions”,
“method”: “POST”,
“headers”: {
“Content-Type”: “application/json”,
“Authorization”: “sanitized”
},
“body”: {
“model”: “gpt-3.5-turbo-instruct”,
“prompt”: “chatgpt what is 7+7”,
“max_tokens”: 2000,
“temperature”: 0
}
}
If that application is not reformatting the body to make the formatted presentation into an acceptable byte stream, then I would remove all the line feeds and indentation and make the JSON of the body completely on a single line.
The API endpoint probably doesn’t like copy-pasted tabs.
