Deploy a Worker that connects to OpenAI via AI Gateway


I am following the exact instructions detailed in here:

As soon as the worker is deployed, the index.js shows an error about: import OpenAI from “openai”;

Cannot find module ‘openai’. Did you mean to set the ‘moduleResolution’ option to ‘node’, or to add aliases to the ‘paths’ option?

No matter what I have tried, I cannot get pass it.

Can someone help me troubleshoot this issue? No errors or any type of issues on the npm terminal while creating this worker. Also, $ npm install openai is installed successfully inside the directory in which I created the project.

Thank you