Secure LLM API Key Management: What Must Stay Server-Side (2026)
Secure LLM API Key Management: What Must Stay Server-Side (2026)
Most AI startup incidents we review start with one issue: a key that should never have reached client-side JavaScript.
Rule of Thumb
- Public key only if provider explicitly marks it publishable and scope-limited.
- Secret key always server-side.
- Admin key never shared with runtime serving user traffic.
7 Controls for LLM API Keys
Fast Audit Checklist
Security Workflows to Run Weekly
- scan exposed API keys
- website security audit
- DNS health check for SPF, DKIM, DMARC
- SSL certificate checker
FAQ
Is a key in NEXT_PUBLIC safe if rate-limited?No for secret keys. Rate limits reduce cost, not exposure risk.
How often should we rotate keys?At least every 30-90 days, and immediately after suspicious activity.
Scan exposed API keys now Check your SSL certificate