API Key Security Best Practices
Your API key is the credential for accessing all Chuizi.AI services. If compromised, others can use your balance to make API calls. Follow these practices to keep your keys secure.
Key Format
Chuizi.AI API keys use the format ck- prefix followed by 32 alphanumeric characters, totaling 35 characters. Example:
ck-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keys are displayed only once at creation and cannot be recovered afterward. Save your key securely immediately after creation.
Never Hardcode Keys
Never embed API keys directly in source code:
# Wrong client = OpenAI(api_key="ck-your-key-here") # Correct import os client = OpenAI(api_key=os.environ["CHUIZI_API_KEY"])
If your repository is public, a hardcoded key is exposed immediately. Even in private repositories, avoid including credentials in code.
Use Environment Variables
Store keys in environment variables or .env files:
# ~/.zshrc or ~/.bashrc export CHUIZI_API_KEY=ck-your-key-here # Or in a .env file at your project root CHUIZI_API_KEY=ck-your-key-here
Make sure .env files are in your .gitignore:
# .gitignore .env .env.local .env.*.local
Least Privilege
When creating a key, restrict its permissions:
- Limit allowed models: Use the
allowed_modelsfield to restrict which models the key can access. For example, allow onlyanthropic/claude-sonnet-4-6instead of all models. - Set an IP whitelist: Use
ip_whitelistto restrict the key to specific IP addresses. Ideal for server-side deployments with static IPs. - Set a daily limit: Use
daily_limitto cap daily spend. Even if the key leaks, the damage is bounded. - Set rate limits: Use
rpm_limitto cap requests per minute.
Regular Rotation
Rotate your API keys every 90 days:
- Create a new key in the Dashboard
- Update all environment variables and configurations that use the old key
- Verify the new key works correctly
- Deactivate the old key in the Dashboard
During rotation, both keys can be active simultaneously for a zero-downtime transition.
Team Usage
When using Chuizi.AI in a team:
- Separate keys per person or project: Makes tracking usage and auditing straightforward
- Never share keys: Avoid multiple people using the same key
- Offboarding: Deactivate a team member's key immediately when they leave
- Use key groups: Categorize keys with the
groupfield (e.g.,production,staging,personal)
Monitor for Anomalies
Check your usage regularly in the Dashboard:
- Usage spikes: A sudden increase in token consumption may indicate a leaked key
- Unexpected models: Calls to models you do not use suggest the key is compromised
- Off-hours activity: High request volumes outside working hours warrant investigation
Responding to a Leak
If you suspect a key has been compromised, act immediately:
- Log in to the Dashboard and deactivate the compromised key
- Create a new key and update all configurations
- Review the usage history of the compromised key for unauthorized activity
- If you find unauthorized charges, contact support@chuizi.ai
Once a key is deactivated, all requests using it immediately return 401 Unauthorized. For the full key specification, see API Key Format.
Next Steps
- API Key Format — Key structure, storage, and management reference
- Data Handling — How Chuizi.AI handles your data and API key hashes
- Sign Up — Create an account and generate your first API key