Skip to main content

How do you manage API keys and secrets across environments?

Deployment and LLMOps · Intermediate 3

Short answer

Never commit secrets to code. Keep them in a secret manager or the platform's encrypted environment variables, with different keys for development, staging and production, scoped to least privilege. Inject them at runtime, rotate them regularly and after any leak, restrict who can read them, and scan repositories for accidental commits.

Deeper answer

If a key does leak, revoke it immediately: deleting the commit is not enough because history and forks keep it. Provider spending limits reduce the damage of a leaked model API key.

Infrastructure as code, such as Terraform, should reference secrets, not contain them, and its state files can hold sensitive values, so store state securely.

What a strong answer covers

Answer it out loud in the mock interview about 1 min

Follow-ups to expect

Common mistakes

Learn it

Environments, secrets and Terraform

Practice Deployment and LLMOps questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.