Streaming is only available in Node.js and Bun. It is not included in the browser build.
Basic Usage
How It Works
The streaming anonymizer uses a sentence buffer that accumulates text until a sentence boundary is detected, then anonymizes complete sentences. This ensures NER has enough context for accurate detection.Stream Configuration
Low-Latency Mode
For real-time LLM token streams where latency matters more than NER accuracy:- Disables NER (regex-only detection)
- Reduces buffer sizes for faster flushing
- Optimized for token-by-token LLM output
Events
onChunk
Fires after each buffered chunk is anonymized:onFinish
Fires when the stream ends:Accessing the PII Map
After the stream ends, retrieve the cumulative PII map:Session Integration
Persist PII maps across streaming sessions:Next Steps
LLM Proxy
Automatic anonymization for LLM API calls
Streaming API Reference
Complete streaming API documentation