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
- Delete or disable the leaked Token in the console.
- Create a new Token and update only trusted application configurations.
- Review request logs and usage after the leak occurred.
- Check for unusual models, unusual IP addresses, unusual charges, or high-frequency requests.
- 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.
