Possible to call OpenAI synchronously from nodejs/AWS lambda?

You are not returning any value from the “mycaller” function. Also, since you’re already in an “async” function you can just await the call and get the response, without using “then”.

For example:

Change the handler function:

...
output = await mycaller(event.prompt);
...

And change mycaller

async function mycaller(prompt) {
   const response = await getResponse(prompt);
   return res.data.choices[0].text;
}