How to hide API key from users

I have created a few tools using HTML and basic JavaScript where I have used the ChatGPT API to make calls in a Wordpress website that is running on a shared web hosting. My API keys are exposed as they are in the javascript files (.js) in a public_html folder. What are the possible ways to hide the API key so that its not misused.

Hello @nahaajayk

Iā€™m afraid that if you call the API from your frontend you cannot hide your API key, so the only option is to prepare a backend (maybe in Node) that interacts with the CahtGPT API using your API key and the backend exposes an endpoint for your website.

1 Like

Since its a shared web hosting, there are limitations on the kind of software that I can use. I tried creating a proxy server using PHP - but the code does not work. Thanks for your response anyway.