Detection is a read-only analysis method that identifies sensitive data in text without transforming it. The original text is not modified — you only receive a list of detected entities with their types, positions, and confidence scores.Example:
Input: "Contact John Doe at john@example.com"Output: [{type: "Person", text: "John Doe", start: 8, end: 16, score: 0.99}, {type: "Email Address", text: "john@example.com", start: 20, end: 36, score: 0.98}]
Monitor what sensitive data flows through your AI agents or applications.
# Check if user input contains sensitive data before processingresult = client.detect(user_input, policy="strict")if result.entities_count > 0: log_violation(user_id, result.detected_entities) block_or_alert()
Understand what PII exists in your datasets before processing.
# Audit a batch of recordsfor record in records: result = client.detect(record) for entity in result.detected_entities: audit_log.append({ "type": entity.type, "confidence": entity.score })
If you need to remove, mask, or replace PII, use the appropriate method directly.
# Detection only tells you WHAT is there — it doesn't change anythingresult = client.detect("SSN: 123-45-6789")# result.detected_entities → [{type: "Social Security Number", ...}]# But the text is unchanged!# Use redact, mask, tokenize, etc. to actually transformredacted = client.redact("SSN: 123-45-6789")
result = client.detect( "John Doe (SSN: 123-45-6789) paid with card 4532-7562-9102-3456", entities=["social security number", "credit card number"])# Only SSN and credit card entities returned
def safe_ai_call(user_message: str) -> str: """Only send to AI if no critical PII detected""" scan = client.detect(user_message, policy="strict") critical = {"Social Security Number", "Credit Card Number"} found = {e.type for e in scan.detected_entities} if found & critical: return "I cannot process messages containing SSNs or credit card numbers." return call_ai_model(user_message)