iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Accept a user’s provider key only through an authenticated, TLS-protected server endpoint. Keep it out of browser or mobile code; if the product must retain it, encrypt it before saving and keep the encryption key separate from the database. Use a backend component to authorize each provider call, retrieve the credential only when needed, and keep it out of logs and diagnostics.
Keep provider keys out of client code
OpenAI’s API reference says: “Do not share it with others or expose it in any client-side code (browsers, apps).” It recommends loading keys from a server environment variable or key-management service. OpenAI API Reference: Authentication
Anthropic likewise advises against putting API keys directly in code or configuration files and discusses using secret-management facilities to pass keys to cloud applications. Anthropic API key best practices
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11For a bring-your-own-key feature, the user submits the key to your server—not to a frontend provider call. Do not place it in browser storage, app bundles, source code, URLs, analytics events, support logs, or client-side error reports.
#1 Best Overall
Choose whether the product needs to retain the key
Do not retain it when a single operation is enough
If the feature can use the key only for the current operation, discard it afterward and tell the user they will need to enter it again next time. Avoid creating a long-lived secret record unless the product actually needs one.
Encrypt it when the product must remember it
Use a managed secrets service if its access controls and operating model fit your application. Otherwise, use envelope encryption: encrypt each submitted provider key before writing it to the application database, and keep the key-encryption key in a restricted key-management service separate from that database. OWASP recommends storing encryption keys separately from encrypted data where possible. OWASP Cryptographic Storage Cheat Sheet
Rank #2
Encryption at rest is not a complete security boundary. Limit which application components and operators can decrypt credentials, authorize access to each record, and establish a way to replace or remove a key. OWASP describes secret-management practices and notes that dedicated secret or key-management systems can add protection and simplify management, while also bringing complexity and administrative overhead. OWASP Secrets Management Cheat Sheet
Implement the key-handling flow
- Authenticate first. Require a signed-in user before accepting a key, and associate the resulting credential record with that user’s internal account identifier.
- Receive it over TLS. Send the value in a server request body, not a URL or client-side provider request. Do not echo the key in a response, including an error response.
- Validate only if needed. If the product needs to check that a key works, make a minimal provider request from the server. Never log the submitted value; provider-specific validation behavior depends on the API endpoint being used.
- Persist safely—or discard. If retention is needed, encrypt before database persistence and store ciphertext with only the non-secret metadata the feature needs. Keep the encryption key outside the database in a restricted key-management boundary. Otherwise, discard the credential after the operation.
- Authorize every use. Before a provider call, verify that the authenticated application user is allowed to use that credential. Decrypt it only in the backend component that needs to make the request.
- Call the provider from the backend. Send the credential to the selected provider over TLS. Keep it out of traces, exception text, metrics labels, request dumps, and debugging output; treat provider error bodies as potentially sensitive.
- Support replacement and removal. Let users update or delete their saved key. Record lifecycle events without recording the secret, and consult the provider’s current official instructions for revocation and rotation procedures.
Decide between a managed secrets service and application-managed encryption
Neither approach removes the need for authorization and careful handling in application code. Compare them against the operational responsibilities your team can support.
Rank #3
- Decryption access: Identify which identities and services can retrieve or decrypt a credential, and how that access is authorized.
- Retention: Determine whether the application can avoid retaining the key at all.
- Rotation and revocation: Make sure users and operators have a workable process to replace or remove credentials.
- Auditability and redaction: Check whether access and lifecycle events can be audited without exposing the key in logs or diagnostics.
- Operational burden: Account for setup, access-policy administration, maintenance, and the additional complexity of a dedicated secrets or key-management system.
Keep OpenAI and Anthropic details distinct
Anthropic’s Claude Platform documentation describes preset expiration periods for Console-created keys of 3 hours, 1 day, 7 days, or 30 days, a custom duration, or “Never” when the key is stored in a secrets manager and rotated by the customer. These are Anthropic-specific options and may change; check the current Claude Platform authentication documentation before building UI or instructions around them.
The cited OpenAI authentication reference supports server-side key handling, but it does not establish corresponding OpenAI key-expiration options. Do not present Anthropic’s choices as applying to OpenAI.
Quick Recap
Best Value
Rank #4
- API Security in Action
- Manning Publications
- ABIS BOOK
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches

