I have a lambda function that moderates input before calling the openai API. It works perfectly in sam local, as well as directly in VSCode (not through my lambda url). When I use my lambda function, I get this error:
{
"error": {
"code": null,
"param": null,
"message": "'input' is a required property",
"type": "invalid_request_error"
}
}
Here is the function that works locally (using SAM CLI invoke)
const moderationResponse = await fetch('https://api.openai.com/v1/moderations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `[PRIVATE]`
},
/* body is stringified before this step
and looks like { input: inputText }
*/
body: moderationBody
})
I'm not really getting any worthwhile logs to try to fix anything.