Chat & LLM Redaction
PII Eraser provides specialized endpoints (/chat/detect and /chat/transform) designed to sit between your users and Large Language Models (LLMs) like GPT-4 or Claude.
Why use the Chat Endpoint?
While you could process chat messages one by one using the Text API, the Chat API offers significant advantages:
- Context Awareness: The model sees the entire conversation history. This improves detection accuracy for ambiguous terms that rely on previous turns of the conversation.
- Structural Integrity: It preserves the OpenAI Chat Format (
system,user,assistant), ensuring that you can forward the output directly to an LLM provider.
Handling Chat History
The API is stateless. PII Eraser does not store conversation history. You must send the relevant history in the messages array with every request.
Example Request
{
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "My name is John."},
{"role": "assistant", "content": "Hello John, how can I help?"},
{"role": "user", "content": "I lost my credit card."}
],
"operator": "redact",
"chat_roles": ["user", "assistant"]
}
Processing Logic
- Roles: By using
chat_roles, you can tell PII Eraser to only redact user input, while leaving System prompts untouched. - Output: The response will return a
messageslist identical in structure to the input, but with PII replaced (e.g.,My name is <NAME>).