PII & Secret Information Masking
Prevent sensitive user information or secrets from landing in cassette files or git repos. Set mask_pii=True to automatically mask sensitive patterns before writing to disk:
with cassette("tests/cassettes", mask_pii=True): # Any email, phone number, API key, etc. will be redacted in the stored cassette response = model.invoke("Send email to alice@example.com or call 555-0199")
Automatically Redacted Patterns:
Emails: alice@example.com → [EMAIL]
Phone Numbers: 555-0199 → [PHONE]
Credit Cards: 4532... → [CREDIT_CARD]
SSN: 000-12-3456 → [SSN]
IP Addresses: 192.168.1.1 → [IP_ADDRESS]
API Keys / Tokens: sk-... → [API_KEY] / Bearer [TOKEN]
