Openrouter Data Privacy
Overview
This skill covers techniques for protecting sensitive data when using the OpenRouter API, including PII filtering, data minimization, and privacy-preserving prompt design.
Prerequisites
- OpenRouter integration
- Privacy requirements defined (GDPR, CCPA, HIPAA, etc.)
Instructions
- Implement PII detection: Scan prompts for personally identifiable information (names, emails, SSNs, phone numbers) using regex or a NLP-based PII detector before sending to the API
- Apply data minimization: Only include data in prompts that is strictly necessary for the task; strip extraneous context, metadata, and user details
- Use placeholder substitution: Replace PII with placeholders (e.g.,
[USER_NAME],[EMAIL]) before sending, then re-substitute in the response - Configure data retention: Review OpenRouter's data retention policy; if your use case requires zero retention, check if the selected providers support it
- Implement consent tracking: Log which users consented to AI processing and only send data for consented users; provide opt-out mechanisms
Output
- PII detection middleware that flags or redacts sensitive data before API calls
- Data minimization checklist for prompt engineering
- Consent tracking system integrated with your user management
Error Handling
| Error | Cause | Fix |
|---|---|---|
| PII detected in prompt | User input contains sensitive data | Block the request and prompt the user to remove PII, or auto-redact |
| Missing consent record | User hasn't consented to AI processing | Block the request and redirect to consent flow |
| Data retention violation | Provider retains data longer than policy allows | Switch to a provider with compatible retention policy; check OpenRouter docs |
See ${CLAUDE_SKILL_DIR}/references/errors.md for full error reference.
Examples
See ${CLAUDE_SKILL_DIR}/references/examples.md for runnable code samples.