Once a business moves beyond individual chat use and starts building AI into websites, apps, and workflows, two new responsibilities appear: protecting the API keys that grant access to AI services, and protecting the customer data that flows through AI features. This article covers practical, proportionate steps for both.
Part 1: API keys
An API key is a secret that lets software use an AI service on your account. Anyone who has it can make requests, access some account features, and run up charges billed to you. Treat API keys like passwords to a company credit card.
Where keys should live
- In a secrets manager or secure environment settings on the server, not in source code.
- On the server side only. Never put an AI API key in website JavaScript, a mobile app, or anything that runs on a visitor's device. Anything shipped to a browser or phone can be extracted. Requests should go through your own server, which holds the key and adds it to requests.
- In restricted files if environment files are used, with permissions limited to the accounts that need them, and excluded from version control.
Where keys should never be
- In code repositories, even private ones.
- In chat messages, emails, tickets, or shared documents.
- In AI prompts.
- In screenshots or screen recordings.
- In logs.
Leaked secrets: API keys and credentials in prompts, code, and logs covers how keys typically leak and what to do if one does.
Limit what each key can do
- One key per application or purpose. If one leaks, you revoke it without breaking everything else, and usage reports show which application is responsible for what.
- Restrict permissions where the provider allows it, such as limiting a key to certain models or endpoints.
- Use separate keys for development and production.
- Avoid personal keys for business systems. Keys should belong to the business account, not an individual who might leave.
Control spending
- Set budget limits and alerts at the provider.
- Use per-key or per-project limits where available.
- For teams, consider centralizing keys behind a gateway that applies per-user and per-model limits and reports usage, so individual staff never handle provider keys directly. Napa AI Gateway works this way, as do several other gateway products and self-hosted proxies.
Rotate and review
- Rotate keys periodically and immediately when someone with access leaves or a leak is suspected.
- Review active keys and delete unused ones.
- Watch usage for unexpected spikes, which can signal a leak or a bug.
Part 2: Customer data in AI features
When customers interact with an AI feature, such as a website assistant, a support tool, or a booking helper, their messages and any data the AI looks up become part of what you are responsible for.
Collect and send only what is needed
- Design AI features to work with the minimum personal information.
- Do not send full customer records to a model when it only needs an order status.
- Strip or mask sensitive fields, such as payment details and government IDs, before they reach a model.
Choose providers with appropriate terms
- Use business or API plans whose terms say your data is not used for training by default. See Will an AI provider train on your data?
- Sign a data processing agreement where required.
- For regulated data, use providers and deployments approved for it, or consider models running in your own environment. See Local AI vs hosted APIs vs private cloud.
Be transparent with customers
- Tell people when they are interacting with AI.
- Update your privacy policy to describe how AI features use and store their data, and which third parties are involved.
- Offer a way to reach a human.
Control access inside your business
- Limit who can view stored AI conversations and logs.
- Use individual accounts, not shared logins, so access can be audited and revoked.
- Turn on multi-factor authentication for AI provider dashboards and any admin tools.
Defend AI features against misuse
Public-facing AI features attract people trying to make them misbehave. Protect against:
- Prompt injection that tries to override your instructions or extract data. See Prompt injection explained.
- Data exposure across customers. Make sure the AI can only look up data belonging to the person it is talking to, enforced by your software, not by instructions to the model.
- Abuse and cost attacks. Rate-limit requests per visitor and consider bot protection on public chat features.
Part 3: Stored conversations
AI conversations often contain more personal information than expected, because people share details freely in chat.
- Decide how long to keep conversations, and delete them on a schedule. Keep only what you need for support, quality, or legal reasons.
- Know where they are stored: your systems, the provider's, an intermediary's, or all three.
- Protect logs with the same care as other customer data, including access controls and encryption.
- Redact sensitive data from logs where possible.
- Honor deletion requests across every place conversations are stored.
A short checklist
- Keys are stored server-side in a secrets manager or restricted environment settings, never in code, chat, or prompts.
- Each application has its own key, with limits and spending alerts.
- Keys are rotated when people leave or leaks are suspected.
- AI features send only the minimum customer data needed.
- Provider terms exclude training on your data, and a DPA is in place where required.
- Customers know when they are using AI and how their data is handled.
- Access to conversations and logs is limited and protected with multi-factor authentication.
- Conversation data has a defined retention period.
Key takeaways
- API keys are secrets that control access and spending; keep them server-side and out of code, chat, prompts, and logs.
- Use separate keys per application, set spending limits, and rotate keys regularly.
- Send AI features only the customer data they need, through providers with appropriate terms.
- Enforce data access rules in software, not just in model instructions.
- Treat stored AI conversations as sensitive customer data with defined retention.