Your backend must enforce the user boundary
The key belongs to your AISwapLab account and can spend its shared balance within the allowed scope. If every visitor can trigger unrestricted requests through your proxy, moving the key off the page alone is insufficient. Your application still needs authentication, authorization, rate controls and a durable user-to-job association.
What to do next
- 01
Separate public and private settings
Expose only non-secret display configuration to the frontend. Store the key in the server's secret environment and verify its presence without logging its value.
- 02
Authorize each task
Check the current application user, approved model and credit ceiling before submitting. Do not accept an arbitrary account owner or unrestricted endpoint from the browser.
- 03
Protect result delivery
Map the returned job to the requesting user in your database. Check that mapping before your backend downloads or streams private content to a client.
A concrete example
Illustrative architecture: the browser sends an approved internal task ID to your backend. The backend loads that user's saved payload and uses its private key. The browser never receives the bearer secret or unrestricted upstream access.
Before you call it ready
- No key reaches a public bundle.
- The proxy checks authenticated user ownership.
- Generation approval cannot be bypassed by editing browser fields.
When to stop or choose another method
If the key has already shipped in a public build, revoke it and deploy a replacement kept server-side. Removing the visible source string alone does not recover secrecy.
