Redact PII from Call Recordings with Python and Telnyx AI Telnyx released a Python Flask example that redacts personally identifiable information (PII) from call transcripts and recordings using its AI inference API. The app replaces common PII types like names, credit card numbers, and SSNs with placeholders and returns structured JSON with a redaction map for audit trails. It supports both text and audio inputs, transcribing audio via the distil-whisper/distil-large-v2 model before redaction. I put together a small Flask example that redacts PII from call transcripts and call recordings using Telnyx AI. Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/call-recording-redactor-python https://github.com/team-telnyx/telnyx-code-examples/tree/main/call-recording-redactor-python The app has two workflows: The prompt asks the model to replace common PII with placeholders: NAME CREDIT CARD SSN PHONE EMAIL ADDRESS DOB ACCOUNT NUMBER The useful part is that the response is structured JSON, not just rewritten text. { "redacted transcript": "Hi, this is NAME calling. My card number is CREDIT CARD .", "redactions": { "type": "name", "original": "John Smith", "redacted": " NAME ", "count": 1 } , "items redacted": 2, "pii types found": "name", "credit card" } That means your app can show the sanitized transcript while still keeping an audit-friendly redaction map. git clone https://github.com/team-telnyx/telnyx-code-examples.git cd telnyx-code-examples/call-recording-redactor-python cp .env.example .env pip install -r requirements.txt python app.py Configure .env : TELNYX API KEY=your telnyx api key AI MODEL=meta-llama/Llama-3.3-70B-Instruct HOST=127.0.0.1 curl -X POST http://localhost:5000/redact \ -H "Content-Type: application/json" \ -d '{ "transcript": "Hi, this is John Smith calling. My card number is 4532-1234-5678-9012 and my SSN is 123-45-6789." }' This calls Telnyx AI Inference through: POST /v2/ai/chat/completions curl -X POST http://localhost:5000/redact/audio \ -F "file=@recording.wav" For audio, the app first calls: POST /v2/ai/audio/transcriptions using: distil-whisper/distil-large-v2 Then it sends the transcript through the same PII redaction flow. POST /redact POST /redact/audio GET /redactions GET /redactions/