Treat keys as financial authority
A stolen model key can expose data and create spend. Never ship a privileged provider or gateway key in browser, mobile, desktop, or public repository code. Client applications should call your authenticated backend or use a narrowly scoped short-lived mechanism designed for that environment.
Give every key a documented owner, workload, environment, and expiry or review date.
Reduce the blast radius
Use separate keys for production, staging, development, services, and important customers where appropriate. Apply model allowlists, rate controls, and hard spend ceilings so compromise cannot access every capability or consume the whole account.
Do not share one key across a company. Shared credentials make rotation risky and investigation ambiguous.
Store, inject, and rotate
Keep secrets in a managed secret store, inject them at runtime, prevent them from entering logs, and scan repositories and build artifacts. Rotation should support overlapping old and new keys so production can move without downtime.
Revoke unused keys and keys whose owner or service no longer exists. Inventory drift is a security bug.
Detect and respond
Alert on unusual model access, geography where available, sudden request or spend changes, repeated authentication failures, and activity outside the workload's normal hours. Link the key to request traces for fast investigation.
Document the response: revoke, rotate, contain the service, inspect logs, notify stakeholders, and review whether the ceiling worked.
