APIrove

Home / API docs / API key security

SECURITY GUIDE

Manage AI API keys securely

Once an API key leaks, other people may be able to make requests on your account. Treat the key like a password: keep it on the server, limit its permissions, and rotate it promptly.

Security practice · About 3 min read

Store keys only on the server

  • Put keys in server-side environment variables or a key management service. Do not write them into web page JavaScript, mobile apps, or desktop clients.
  • Do not commit real keys to Git or put them in public issues, build artifacts, or screenshots.
  • For local development, use an environment file that version control ignores, and restrict the file's read permissions.
  • In CI/CD, use the project's secret management feature and avoid printing keys to logs in plain text.

Use least privilege

Create a separate key for each application, and set allowed models, quota, and expiry (if the console supports it). Do not reuse production keys in test environments, and regularly review keys that are no longer in use.

How to rotate an API key

  1. Create a new key and add it only to trusted server-side configuration.
  2. Verify the new key with a small amount of traffic before switching production traffic.
  3. Once the new key works correctly, revoke the old key immediately.
  4. Check usage records and application logs to confirm there are no unusual calls.

If you suspect a key has leaked

First disable or delete the leaked key in the console, then review recent requests and charges. Update the configuration in CI/CD, on servers, and in local development environments; check commit history and copies of logs so the same key does not appear again. If you cannot sign in or you see unusual usage, contact support at help@apirove.com.

API keys are only for authenticating your server to APIrove. Public browser code cannot safely hide a long-lived key.

Back to the OpenAI-compatible API integration guide →