This document provides a technical specification for the FastAPI Bridge proxy, serving as a zero-latency PII scrubbing middleware.
- Endpoint:
/v1/chat/completions(OpenAI Compatible) - Method: POST
- Payload Schema:
{
"model": "gpt-4",
"session_id": "unique-session-id-001",
"messages": [
{"role": "user", "content": "Send it to john.doe@acme.com for review."}
],
"temperature": 0.7,
"stream": false
}- PII Extraction: The Bridge sends the user content to the
micro-f1-maskmodel in Ollama. - Vault Storage: Detected PII (e.g.,
john.doe@acme.com) is stored in Redis under thesession_id. - Scrubbing: The user content is masked (e.g.,
Send it to [CONTACT_1] for review.). - Cloud Forwarding: The masked prompt is sent to the
CLOUD_LLM_URL(OpenAI, Claude, etc.). - Reconstruction: The Cloud LLM response is scanned for tokens (e.g.,
[CONTACT_1]) and replaced with original values. - Response: The user receives the full reconstructed response.
- Persistence: Mapping is stored in Redis.
- Isolation: Each
session_idhas a unique namespace. - Consistency: Within a session, the same PII value always maps to the same token.
- TTL: Default expiration is 7,200 seconds (2 hours).
| Variable | Default | Description |
|---|---|---|
| OLLAMA_URL | http://localhost:11434/api/chat | Endpoint for PII detection. |
| F1_MASK_MODEL | micro-f1-mask | Ollama model name. |
| CLOUD_LLM_URL | https://api.openai.com/v1/chat/completions | Target cloud API. |
| REDIS_HOST | localhost | Redis host. |
Built & Maintained by ARPA Hellenic Logical Systems