AI and LLMs · Junior · Question 27 of 75
Where should the API key for an LLM provider live in a web app?
- 1On the server, never in frontend code
- 2In the JavaScript bundle, for speed
- 3In the HTML as a hidden input field
Show the answer
Correct answer: On the server, never in frontend code
Explanation
Anything shipped to the browser can be read. A leaked key lets anyone run requests on your bill. The frontend calls your own backend instead.