Hello everyone,
I share with you my code bellow to get a response from a POST request with R :
param ← list(model=“gpt-3.5-turbo”,messages = c(“role” = “user”,“content” = “Hello”))
result ← POST(“https://api.openai.com/v1/chat/completions”,body = param,add_headers(Authorization=openai_secret_key), encode = “json”)
Here is the result :
Response [https://api.openai.com/v1/chat/completions]
Date: 2023-03-02 16:28
Status: 400
Content-Type: application/json
Size: 158 B
{
“error”: {
“message”: “‘user’ is not of type ‘object’ - ‘messages.0’”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
So the user and the content part is not working. Do you have an idea why ?
Thanks a lot