DEV Community

modelkiwi
modelkiwi

Posted on

Your API key probably already leaked (check in 5 minutes)

git log -p | grep "sk-". If that command returns anything, your key is in your Git history. This 20-minute checklist can save you from a surprise bill.

A leaked API key is an open credit card — someone can burn your balance in hours. And the most common leak isn't a hack: it's the developer.

The 4 most common mistakes:

  1. Key in frontend code — anyone can open DevTools and copy it. Calls to AI providers must come from the backend, period.
  2. Key committed to Gitgit log -p | grep "sk-". Use .gitignore, secret scanners (gitleaks/trufflehog), and rotate the key now.
  3. Key in unprotected env vars — env vars are the minimum, not security. Use a secret manager and least-privilege keys.
  4. No spending limit — set a cost ceiling on the provider/gateway so a leak has limited damage.

Quick checklist:

  • No keys in frontend code
  • .env in .gitignore
  • Keys rotated if ever exposed
  • Spending limit configured
  • Access audited

Key security is 20 minutes of work that prevents a nasty surprise bill.


Want to try these models in your project? **ModelKiwi* gives you access to GPT, Claude and Gemini with PIX payment (no international credit card needed) and free credits to start: https://www.modelkiwi.com. WhatsApp: +5521999500402 — and join our channel: https://t.me/ModelkiwiOfficial.*

Top comments (0)