DEV Community

Daniel Dong
Daniel Dong

Posted on

Your AI API Key is Probably Exposed (Fix It in 5 Min)

You're shipping frontend code with AI API keys hardcoded. 💥

The problem:

// Don't do this!
const apiKey = "sk-...";  // ← Exposed in bundle
Enter fullscreen mode Exit fullscreen mode

Anyone can extract it. Then abuse your quota. 💸

The fix: Proxy through AIBridge (or your own backend).

# Backend: AIBridge handles auth
client = OpenAI(
    api_key="mb_your_key",  # ← Never exposed
    base_url="https://aibridge-api.com/v1"
)

# Frontend: Calls YOUR backend only
fetch("/api/ai", { method: "POST", body: ... })
Enter fullscreen mode Exit fullscreen mode

Why AIBridge helps: ✅ Keys never leave your backend
✅ Usage analytics (spot abuse early)
✅ Rate limiting built-in
✅ One key for 14+ models

Get started: https://aibridge-api.com

Secure your AI. 🔒

mainpage

models

playground

pricing

Top comments (0)