Getting Started¶
Protect sensitive data in your AI applications. This guide gets you from zero to PII-safe AI in under 5 minutes.
Prerequisites¶
- Python 3.9 or higher
Step 1: Install the SDK¶
Or with optional dependencies:
pip install aegis-sdk[openai] # For OpenAI integration
pip install aegis-sdk[anthropic] # For Anthropic integration
pip install aegis-sdk[all] # All integrations
Step 2: Initialize the SDK¶
from aegis_sdk import Aegis
# Basic initialization (no license required for core features)
aegis = Aegis()
# Or with a license key for enterprise features
aegis = Aegis(license_key="aegis_lic_xxx")
Step 3: Process Content¶
Basic Processing¶
# Process text before sending to AI
result = aegis.process(
text="Contact [email protected] or call 555-123-4567",
destination="AI_TOOL"
)
print(f"Decision: {result.decision}")
print(f"Summary: {result.summary}")
print(f"Masked: {result.masked_content}")
Output:
Decision: Decision.ALLOWED_WITH_MASKING
Summary: Content allowed after masking EMAIL, PHONE
Masked: Contact j***@example.com or call XXX-XXX-4567
Detection Only¶
# Just detect sensitive data
detected = aegis.detect("Customer SSN: 123-45-6789")
for item in detected:
print(f" - {item.type}: {item.count} occurrence(s)")
Masking Only¶
# Just mask sensitive data
masked = aegis.mask("Email: [email protected]")
print(masked) # Email: j***@example.com
Step 4: Handle Decisions¶
Decision Types¶
| Decision | Meaning | Action |
|---|---|---|
ALLOWED |
Content is safe | Proceed with original |
ALLOWED_WITH_MASKING |
PII was redacted | Use result.masked_content |
BLOCKED |
Content violates policy | Do not send |
Example Handler¶
from aegis_sdk import Aegis, Decision
aegis = Aegis()
def send_to_ai(content: str) -> str:
"""Safely send content to AI with Aegis protection."""
result = aegis.process(content, destination="AI_TOOL")
match result.decision:
case Decision.BLOCKED:
raise ValueError(f"Content blocked: {result.summary}")
case Decision.ALLOWED_WITH_MASKING:
return call_ai_api(result.masked_content)
case Decision.ALLOWED:
return call_ai_api(content)
Step 5: Use LLM Wrappers (Optional)¶
For the simplest integration, use drop-in replacement clients:
OpenAI¶
from aegis_sdk import AegisOpenAI
# Drop-in replacement - PII automatically masked
client = AegisOpenAI(api_key="sk-...")
response = client.chat.completions.create(
model="gpt-4",
messages=[{
"role": "user",
"content": "Customer email: [email protected]"
}]
)
# OpenAI only sees: "Customer email: j***@example.com"
Anthropic¶
from aegis_sdk import AegisAnthropic
client = AegisAnthropic(api_key="...")
message = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[{
"role": "user",
"content": "My SSN is 123-45-6789"
}]
)
# Claude only sees: "My SSN is XXX-XX-6789"
Complete Example¶
from aegis_sdk import Aegis, Decision
aegis = Aegis()
# Sample content with sensitive data
content = """
Customer Support Ticket #12345
Customer: Jane Doe
Email: [email protected]
Phone: (555) 123-4567
SSN: 987-65-4321
Issue: Unable to access account. Please reset password.
"""
# Process before sending to AI assistant
result = aegis.process(content, destination="AI_TOOL")
print(f"Decision: {result.decision}")
print(f"Summary: {result.summary}")
print()
if result.detected:
print("Detected sensitive data:")
for item in result.detected:
print(f" - {item.type}: {item.count} found")
if result.decision == Decision.ALLOWED_WITH_MASKING:
print("\nMasked content:")
print(result.masked_content)
Output:
Decision: Decision.ALLOWED_WITH_MASKING
Summary: Content allowed after masking EMAIL, PHONE, SSN
Detected sensitive data:
- EMAIL: 1 found
- PHONE: 1 found
- SSN: 1 found
Masked content:
Customer Support Ticket #12345
Customer: Jane Doe
Email: j***@example.com
Phone: XXX-XXX-4567
SSN: XXX-XX-4321
Issue: Unable to access account. Please reset password.
CLI Quick Start¶
The SDK includes a command-line tool:
# Scan for PII
aegis scan "Contact [email protected]"
# Mask PII
aegis mask "My SSN is 123-45-6789"
# Process with policy
aegis process "Customer data here" -d AI_TOOL
# Check version
aegis --version
Next Steps¶
- SDK Installation - Detailed installation options
- SDK Quick Start - More examples and use cases
- API Reference - Full SDK documentation
- CLI Reference - Command-line tool usage
- LLM Integrations - OpenAI, Anthropic, LangChain
Troubleshooting¶
Import Errors¶
Solutions:
- Ensure you're in the correct virtual environment
- Reinstall:
pip install --upgrade aegis-sdk - Check Python version:
python --version(requires 3.9+)
License Validation Failed¶
Solutions:
- Verify your license key is correct
- Check your internet connection
- Use basic mode without license:
aegis = Aegis()