PromptGuard uses API keys to authenticate requests. Your API key carries many privileges, so be sure to keep it secure!
API Key Format
PromptGuard API keys follow this format:pg_live_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxx
pg_- PromptGuard prefixlive_- Environment (live for production, test for development)8 characters- Key identifier24 characters- Secret portion
Creating API Keys
Via Dashboard (Recommended)
- Log in to app.promptguard.co
- Select your project
- Navigate to Settings > API Keys
- Click Create API Key
- Name your key (e.g., “Production App”, “Development”)
- Set permissions (read, write, admin)
- Copy the key immediately - it won’t be shown again
Via Dashboard API
You can also create API keys programmatically using the dashboard API (requires session authentication):Using API Keys
In Headers
Include your PromptGuard API key in theX-API-Key header:
Authorization header:
Environment Variables
Store your API key in environment variables, not in your code:API Key Scope
API keys are scoped to specific projects. Each key provides access to:- Make AI requests through the proxy endpoint (
/api/v1/chat/completions, etc.) - View usage and analytics for the associated project
- Inherit project security settings (presets and custom policies)
Key Management Best Practices
- One key per environment: Use different projects and keys for dev/staging/prod
- Rotate regularly: Create new keys and delete old ones every 90 days
- Monitor usage: Check dashboard regularly for unusual activity
- Store securely: Never commit keys to version control
Key Management
Listing Keys
View all your API keys via the dashboard:Rotating Keys
Regularly rotate your API keys for security:- Create a new API key
- Update your applications to use the new key
- Test thoroughly
- Delete the old key
Deleting Keys
Security Best Practices
✅ Do
- Use environment variables for API keys
- Rotate keys regularly (every 90 days)
- Use separate keys for different environments
- Grant minimal permissions required
- Monitor key usage in the dashboard
- Delete unused keys immediately
❌ Don’t
- Never commit keys to version control
- Don’t share keys between team members
- Don’t use production keys in development
- Don’t log API keys in application logs
- Don’t embed keys in client-side code
Development vs Production
Use separate API keys for different environments:Rate Limits
API keys are subject to rate limits based on your plan:| Plan | Requests/Minute | Burst |
|---|---|---|
| Free | 100 | 200 |
| Starter | 100 | 200 |
| Growth | 1,000 | 2,000 |
Rate limits are per API key, not per project. Distribute load across multiple keys if needed. For higher limits, contact [email protected].
Troubleshooting
Invalid API Key Error
-
Check your API key format: Your key should start with
pg_live_orpg_test_followed by 8 characters, an underscore, and 24 characters- ✅ Correct:
pg_live_12345678_abcdefghijklmnopqrstuvwx - ❌ Wrong:
pg_live 12345678(has a space)
- ✅ Correct:
- Verify there are no extra spaces: Copy your key again from the dashboard and ensure there are no leading/trailing spaces
- Check if the key was deleted: Navigate to your project dashboard → API Keys to see if the key still exists
-
Verify environment match: Make sure you’re using:
pg_live_...keys in productionpg_test_...keys in development
- Try creating a new key: If issues persist, create a new API key from your dashboard
Project Mismatch Error
-
Check your API key’s project:
- Go to your dashboard → Projects → API Keys
- Verify which project the key belongs to
-
Use the correct key:
- Ensure you’re using an API key from the project you want to access
- Create a new key in the correct project if needed
-
Verify project settings:
- Check that the project has the correct preset and policies configured
- Ensure the project is active and not deleted
- Contact support: If issues persist, email [email protected]
Rate Limited Error
-
Implement exponential backoff in your code to retry requests with increasing delays:
- Distribute requests across multiple API keys to stay within per-key limits
- Check your current usage in the dashboard to see how close you are to your limits
-
Upgrade your plan if you consistently hit rate limits:
- Visit app.promptguard.co → Billing
- Choose a plan that matches your usage needs
- Or contact [email protected] for custom limits