AI API Credential Management
Securely manage, rotate, and audit API keys and credentials used to access AI services and model providers.
Objective
Prevent unauthorized access to AI capabilities and associated cost liability through disciplined credential hygiene.
Maturity Levels
Initial
API keys are shared informally and stored in code repositories or plain text files.
Developing
Keys are managed individually but without a centralized store, rotation schedule, or usage auditing.
Defined
All AI API credentials are stored in a secrets manager, with documented rotation schedules and access controls.
Managed
Credential usage is monitored; anomalous spend or usage patterns trigger alerts.
Optimizing
Credentials are scoped to specific services and rotated automatically; compromise detection response time is measured.
Evidence Requirements
What an auditor or assessor would expect to see for this control.
- —Credential inventory listing all AI API keys, storage location, scope, and rotation schedule
- —Secrets manager access control configuration confirming developer direct production access is restricted
- —Rotation completion records showing each credential was rotated on schedule
- —Spending alert configuration and records of any alerts triggered and investigated
- —Source code repository scan results confirming no AI API keys are committed to version control
Implementation Notes
Key steps
- Never hardcode AI API keys in application code or commit them to source control — use environment variables or a dedicated secrets manager.
- Scope credentials to the minimum required permissions; many AI providers offer read-only or rate-limited key types.
- Set spending limits and usage alerts on AI API accounts — compromised keys are often discovered first through unexpected billing spikes.
- Rotate keys on a defined schedule and immediately upon any suspected compromise or personnel change.
Example Implementation
Startup using OpenAI, Anthropic, and a vector DB provider across three products
AI API Credential Inventory and Rotation Policy
| Provider | Key Scope | Storage | Rotation Schedule | Spend Alert Threshold |
|---|---|---|---|---|
| OpenAI | Production (GPT-4o) | AWS Secrets Manager | 90 days | $500/day |
| OpenAI | Development | AWS Secrets Manager | 30 days | $50/day |
| Anthropic | Production | AWS Secrets Manager | 90 days | $500/day |
| Pinecone | Read + write (prod index) | AWS Secrets Manager | 90 days | N/A |
Prohibited storage locations: Source code, environment files committed to git, Slack/email, shared spreadsheets
Compromise response: Immediate rotation + incident report within 1 hour of detection; notify Security Lead
Access control: Secrets Manager access restricted to CI/CD service role and designated engineering leads; no developer direct access in production
Control Details
- Control ID
- SEC-004
- Domain
- Security
- Typical owner
- CISO / Platform Engineering
- Implementation effort
- Low effort
- Agent-relevant
- Yes
