[POST] /api/gpt reason=EDGE_FUNCTION_INVOCATION_FAILED, status=500, user_error=true
Unanswered
Yellow-eyed Junco posted this in #help-forum
Yellow-eyed JuncoOP
I'm trying to run a edge function for openAI's api. I don't see any request body in local or in dev. I tried creating a middleware.js but it's throwing the above error.
serverless works fine though
serverless works fine though
8 Replies
do u use OpenAI's SDK to invoke OpenAI API from Edge Runtime? if so, it won't work. instead use Vercel version AI SDK, which is tweaked to work in Edge.
under the hoold, OpenAI SDK uses axios, which does not work in Edge.
Yellow-eyed JuncoOP
No, I'm not using the SDK
I just have the openai's npm package
@tafutada777 https://sdk.vercel.ai/docs/guides/openai
Yellow-eyed JuncoOP
Does Vercel allow for over 10s though?
yes if you deploy on Edge Runtime, where the cap is measured by CPU time 50ms instead of wall time. usually chatbots is I/O bound so CPU is almost idle.
Yellow-eyed JuncoOP
Cool, let me try switching