Migrating to PromptGuard is designed to be seamless. This guide walks you through migrating any existing OpenAI integration with minimal code changes and zero downtime.
Migration Overview
PromptGuard acts as a secure proxy that’s 100% compatible with OpenAI’s API. The migration typically requires changing just 2 lines of code:- API Key: Switch from OpenAI key to PromptGuard key
- Base URL: Route requests through PromptGuard’s secure proxy
Pre-Migration Checklist
- OpenAI API integration currently working
- PromptGuard account created (sign up)
- PromptGuard API key obtained (get one here)
- Development environment for testing
Step-by-Step Migration
Step 1: Environment Setup
Add your PromptGuard API key to your environment. See Authentication for detailed setup instructions..env
Step 2: Update Client Configuration
Modify your OpenAI client initialization:Step 3: Update Error Handling
Enhance your error handling to account for PromptGuard’s security features:Step 4: Test Your Migration
Verify your core use cases work with PromptGuard:- Test basic functionality: Make a simple request
- Test security features: Try a potentially malicious prompt
- Test your models: Verify all models you use work correctly
Step 5: Monitor Your Migration
After migrating, monitor your requests in the dashboard:- View security events and blocked requests
- Monitor latency and performance
- Track usage and costs
PromptGuard adds minimal latency (typically ~0.15s). Monitor your dashboard to see actual performance impact.
Framework-Specific Examples
Express.js / Node.js
FastAPI / Python
Rollback Plan
If you need to rollback, simply revert the two changes:- Change
PROMPTGUARD_API_KEYback toOPENAI_API_KEY - Remove the
baseURLparameter
Next Steps
Integration Guides
Detailed setup for Node.js, Python, React, and more
Security Configuration
Customize protection for your use case
Monitoring Dashboard
Track security events and performance
Troubleshooting
Common issues and solutions