Skip to content

What should I do if my API Key is leaked? ​

A leaked API Key must be handled immediately. Others may use the leaked Key to consume your quota, call high-cost models, or access business capabilities they should not have access to.

Immediate actions ​

  1. Delete or disable the leaked Token in the console.
  2. Create a new Token and update only trusted application configurations.
  3. Review request logs and usage after the leak occurred.
  4. Check for unusual models, unusual IP addresses, unusual charges, or high-frequency requests.
  5. If the leak occurred in a public repository, delete the history or rotate the relevant environment variables.

Further hardening ​

  • Create separate Tokens for different applications.
  • Set quotas, expiration times, model scopes, and IP allowlists.
  • Do not put long-lived Tokens in frontend code or public configurations.
  • Use environment variables or a secrets management system to store the Key.