orq.aiAdvent of Routing

Door 19 · still sealed

Hands off the wax, elf. This door opens on Dec 19.

-days--hours--min--sec

Rudolph is still polishing this one. Back to the calendar

Door 19 · Dec 19 PII redaction

Addresses stay secret

Your app sends real names and addresses. The provider only sees placeholders like <PERSON_1>, and the reply comes back with the real ones restored.

The reply desk is buried in letters, each with a child's name and home address. Sprocket has found an outside model that drafts replies faster than any elf, and he wants it on tonight.

  1. Sprocket

    The new model writes lovely replies! I'm sending it every letter, addresses and all.

  2. Mrs. Claus

    Lovely. And once they leave the workshop, who else gets to read those addresses?

  3. Sprocket

    Fine, I'll swap them for XXXX first. Oh no. Now every reply says "Dear XXXX, your present is on its way to XXXX."

  4. Mrs. Claus

    Add the pii_redaction plugin, dear. The model writes to <PERSON_1>. The router keeps the list of who's who and puts the real name back.

clientYour appdana@example.comorq.aiPII redactionpii_redaction pluginprovideropenai/gpt-6-lunasees <EMAIL_ADDRESS_1>orq.aiReply restoreddana@example.com againredactedrestored
  1. clientYour appdana@example.com
  2. orq.aiPII redactionpii_redaction plugin
  3. provideropenai/gpt-6-lunasees <EMAIL_ADDRESS_1>
  4. orq.aiReply restoreddana@example.com again
Dana's email leaves the router as a placeholder, the provider writes its whole reply to that placeholder, and the router puts the real address back before your app reads it.

How it works

Mrs. Claus’s fix is one entry in the plugins array. The router then runs a round trip around the model call:

  1. Redact. The plugin detects PII in your request and replaces each value with a typed placeholder, such as <EMAIL_ADDRESS_1> or <PERSON_2>, before the request leaves the router (the AI Gateway).
  2. Generate. The provider works on the placeholder text and returns a reply that keeps the placeholders intact.
  3. Restore. The router substitutes the original values back into the reply before it returns it to you.

Detection runs on Orq’s own model, on Orq infrastructure. The docs state that text is never sent to a third-party service for detection. The feature is in Beta.

Try it with curl

curl -X POST https://my.orq.ai/v3/router/responses \
  -H "Authorization: Bearer $ORQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-6-luna",
    "input": "Write a thank-you note to Dana Frost at dana@example.com",
    "plugins": [{"id": "pii_redaction", "language": "en"}]
  }'

Or from the OpenAI SDK

plugins is not part of the OpenAI request types, so pass it in extra_body:

import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ORQ_API_KEY"],
    base_url="https://my.orq.ai/v3/router",
)

response = client.chat.completions.create(
    model="anthropic/claude-haiku-5-5",
    messages=[{
        "role": "user",
        "content": "Confirm delivery to Dana Frost, "
                   "Elf Lane 1, Utrecht, by email to dana@example.com",
    }],
    extra_body={
        "plugins": [{
            "id": "pii_redaction",
            "language": "en",
            "entities": ["PERSON", "LOCATION", "EMAIL_ADDRESS"],
        }],
    },
)
print(response.choices[0].message.content)

Choosing what to redact

Setting What gets redacted
Neither regions nor entities Every region, base types included
entities only Only the named types
regions only The base catalog plus the types those regions add
Both The region coverage plus the named types

language accepts en, nl, de, es, fr, it or auto, and defaults to auto. Region codes are lowercase ISO codes such as nl, gb and us. US types such as US_SSN are gated by the us region, not by language: en. If you set regions or entities, include us or name the type.

Redact, block or mask

These are three different controls. The pii_redaction plugin rewrites the request and restores the reply. The orq_pii_detection guardrail blocks the request instead, and it always fails closed: you cannot set on_failure on it. Trace scrubbing and masking only change what is stored in traces, while the provider still receives everything.

By default the plugin also stores the placeholder form in traces (persist_redacted_to_traces is true).

When detection is down

The detection service waits up to 90 seconds by default. Then on_failure applies: block rejects the request, passthrough sends the original text to the provider.

Redaction runs on the Responses, Chat Completions, Completions, Embeddings, Rerank, Images, Anthropic Messages, Web Search and Deployments routes. Embeddings and Images redact the input only, because there is no echoed text to restore.

A Deployment invoke takes no plugins array. There, redaction runs only when the workspace setting is on or a Routing Rule or Guardrail Rule carries the plugin.

Nice list

  • Keep on_failure at its default, block. If detection cannot run, the request is rejected and nothing reaches the provider.
  • Leave persist_redacted_to_traces at its default, true. Your traces then store <PERSON_1> instead of the child's real name.
  • Read the live entity list from GET /v2/pii/capabilities. The docs call it the source of truth and their own lists a snapshot.
  • Leave threshold at 0.5 until you see a problem: lower it if PII slips through, raise it if too much gets redacted.

Naughty list

  • Setting on_failure: passthrough on sensitive traffic. When detection is down, the original, un-redacted text goes to the provider.
  • Blanking names with XXXX yourself. The reply comes back addressed to XXXX, because nothing kept the mapping to put the real name back.
  • Writing "uk" in regions. The United Kingdom is gb.
  • Sending sensitive text to a route outside the supported list. On those routes, request content reaches the provider unredacted.

Elf's challenge

Play the outside model: run orq pii redact --text "Deliver to Dana Frost, dana@example.com" --entities EMAIL_ADDRESS -o json. What can you still read in redacted_text, and why?

Stuck? Ask Mrs. Claus for a hint

The name. entities on its own is a strict allowlist, so only EMAIL_ADDRESS is swapped for a placeholder. mappings tells you which placeholder stands for which original value.

Christmas crackerWhy is the model provider the perfect Secret Santa?Pull it for the punchline

It writes every letter and never finds out who it's for.