If your app has more than one AI feature, there's a good chance they all share one provider API key. It's the default path: a key gets created during prototyping, dropped into an env var, and reused by every new feature after that.
Here's why that's worth fixing, and a simple pattern for doing it.
Problems with a shared key
- Blast radius. A bug in one consumer (a batch job stuck in a retry loop, for example) can exhaust limits or budget for every feature, including customer-facing ones.
- Big-bang rotation. A leak from one service forces you to rotate and redeploy everything simultaneously.
- No attribution. Spikes in usage are hard to trace back to a feature.
- Over-permission. Every caller can hit every model, including the most expensive one.
The pattern
Treat AI keys like any other credential and apply least privilege:
support-bot-prod models: [small-chat-model] tokens/day: sized to usage rate: modest
summariser-staging models: [summary-model] tokens/day: small rate: low
model-test-dev models: [any under test] tokens/day: very small rate: low
nightly-batch-prod models: [batch-model] tokens/day: sized to job ip-allowlist: job egress IP
(Illustrative names and fields; use your provider's or gateway's actual options.)
- One key per feature per environment, with self-explanatory names.
- Restrict each key to the models it needs.
- Set per-key token and rate limits; keep experiment keys small.
- Add IP allowlists for server-side callers with fixed egress.
- Keep a register: key, owner, feature, limits, last rotated.
- Store keys in a secrets manager or env vars; never in the repo or frontend bundle.
Operating it
- Migrate one feature at a time, then retire the shared key.
- Run a practice rotation on a low-risk key.
- Incident playbook: freeze the misbehaving feature's key first, investigate second.
- Weekly five-minute review: orphaned keys, oversized limits, overdue rotations.
Using a gateway
With multiple model providers, a gateway centralises this. OROO Blue is a secure AI gateway for Indian teams and developers: one API for OpenAI, Google and Anthropic models (oroo-chatgpt, oroo-gemini, oroo-claude), per-key model/token/rate limits, freeze/rotate/revoke per key, IP allowlists, and key secrets shown once and hashed. Idempotency keys prevent double charges on retries, billing is via a prepaid INR wallet (OROO Mint) where you pay only for tokens used, and OROO doesn't store prompts or completions.
The longer write-up with a rollout checklist is on the OROO Kids blog.
How do you scope AI keys on your team?
Top comments (0)