API Key in a Frontend AI App: How to Move the Model Call Off the Page
A practical case story about securing client-side AI calls
The feature was doing its job: a user entered a prompt, the app sent it to a model, and a useful reply appeared on screen. People were using it. The founder had built it using modern AI builders like Lovable and Bolt, improving it continuously as the business grew.
This is a composite situation, not a documented Smicolon customer case.
Then the founder asked a question that a working screen cannot answer: where does the model API key live in the live app?
When using tools like Lovable, Bolt, Replit, or Cursor, calling a model provider directly from the browser can be a rapid way to validate whether a concept works. The page sends a prompt, receives a response, and displays it. That speed is why these tools are so effective for getting an idea off the ground.
However, a live production page is different from a private preview. It is delivered to every visitor's browser. When you leave an api key in frontend ai app code or browser network requests, any visitor using developer tools can inspect it. The founder was not looking to discard a working feature. They simply needed to resolve an exposed model key Lovable Bolt setup by shifting the client side API key AI builder pattern to a protected backend architecture.
The key was visible in the live request
The founder asked a technical person to inspect the live app, rather than the editor or a local preview. They opened the browser developer tools, used the model-powered feature, and checked the network tab.
The browser was contacting the model provider directly, sending the secret key in the request headers. The person checking also reviewed the compiled JavaScript files to see whether the key was bundled there.
That is the practical risk of an api key in frontend ai app architecture. Any code, asset, or network request delivered to a visitor's browser can be inspected. A secret is not secure simply because it does not appear on the screen, or because it is bundled into a minified script. As teams scale their applications, addressing AI code quality as an appsec problem becomes essential to protecting infrastructure.
Testing this does not require pasting credentials into third-party scanners. A direct inspection in the browser console provides the answer: “Does the browser client receive or transmit our model key?”
This established exposure, not theft. Nothing in this composite situation indicated that anyone had copied or misused the key.
