Bosphorus

← Knowledge base

Mask IP addresses before they reach an external model

An administrator sets up a guardrail that sends a model <IP_001> instead of a real address, checks the answer, and puts the real address back for the user.

GovernanceGuardrailsPrivacyChecked against the product on

Every place a rule is applied, for the two kinds of traffic that cross the gateway. A policy step is the same engine, the same rules and the same audit record, whichever client sent the request.

A model request

From aimo, agents, the editor extension, Claude Code, Ollama clients and any OpenAI-compatible SDK, in all three API dialects.

  1. Who is asking

    The personal key, service key or signed-in session is resolved to a person, a key and a team.

  2. Which model, which lane

    An alias becomes a concrete model, and with it the lane that would serve it: your own hardware or an external provider.

  3. policy

    May this content pass

    The whole conversation (system prompt, earlier turns, retrieved documents, tool results) is checked against every enabled rule. An enforcing hit refuses the request and cites the instrument; a shadow-mode hit is only recorded.

  4. policy

    Or continue without it

    If the flagged content sits only in earlier messages, those messages are replaced with a placeholder, the rest is checked again, and the request goes ahead without them.

  5. Quota, rate limit, fair share

    Only a request that passed policy can spend a budget or take a place in the queue.

  6. The model answers

    On your own hardware or at the provider. The request and the answer are written to the audit record.

  7. policy

    Response scan, if switched on

    The delivered answer is checked for identifiers and secrets. A hit is recorded for administrators; nothing is blocked or changed.

A tool call

When a model asks for a tool, the client sends the call to the gateway's relay, never straight to the tool server, whose address and credential it never sees.

  1. Who is asking, and may they

    Team scope and per-person grants apply. A server someone may not use looks exactly like one that does not exist.

  2. policy

    Are these arguments allowed

    The tool name and its arguments are checked by the same rules as a prompt. A refusal returns HTTP 403 with the rule's reason, and the tool is never called.

  3. The tool runs

    With its credential added on the server side. The call, its arguments and its result are written to the audit record.

  4. Sensitive results carry a stamp

    Tool servers whose results must stay inside, such as training-progress records and accounting data, put a stamp on the first line. Retrieved company documents carry one too.

  5. policy

    The next request decides

    The result is now part of the conversation. Sent to your own hardware, it passes. Sent to an external provider, it is removed from the context first, or the request is refused if the stamp is in the message being sent.

A network engineer pastes a fault into chat: “192.0.2.40 ile 203.0.113.8 haberleşemiyor” — two hosts that cannot talk to each other. If the chat runs on an external model, those addresses leave your network with the question. This article sets up a guardrail that keeps them home. The model receives <IP_001> and <IP_002>, answers in those terms, and the person reads the answer with the real addresses back in place. The Turkish case suffix is corrected too, so <IP_001>'in comes back as 192.0.2.40'ın, because kırk takes -ın.

Everything below was done on a live system on 17 October 2026, by an administrator, in the console only. The screenshots and responses are real, with names and addresses replaced.

At a glance

Who does what

Who What Where
Administrator Creates the guardrail and a profile, gives the profile to a key, turns the pipeline on Guardrails, Teams & Keys
Whoever holds the key Sends requests as usual; nothing changes on their side their client, ai.corp.example
Administrator Reads what happened, then rolls back or widens the scope Activity, Guardrails

The flow

user      192.0.2.40 ile 203.0.113.8 haberleşemiyor
            |  OPA (pii-mask) finds the addresses
gateway   <IP_001> ile <IP_002> haberleşemiyor
            |
model     <IP_001>'in routing ayarlarını kontrol edin
            |  OPA checks the answer, still masked
gateway   <IP_001>  ->  192.0.2.40,  'in  ->  'ın
            |
user      192.0.2.40'ın routing ayarlarını kontrol edin

The same guardrail does both OPA steps: on the way out it masks, on the way back it checks. Only the gateway ever holds the link between a placeholder and an address, and only for the length of the request.

Before you start

Part 1 — Set it up (administrator)

Step 1: create the guardrail

Open Guardrails and scroll to New guardrail. Fill it in as below and press Create guardrail.

The New guardrail form filled in: slug opa-mask, kind opa, mode enforce, phases request and response, actions deny and mask, fail open, timeout 1500, config suffixHarmony tr

Field Value Why
Slug opa-mask Any name; profiles refer to it.
Kind opa Uses the policy engine’s pii-mask rules.
Mode enforce monitor would only record what it would have done.
Phases request and response Request: mask on the way out. Response: check the answer.
Actions deny and mask Mask the request; deny an answer that leaks an address.
Fail open on If the check cannot run, the request goes ahead and the failure is recorded.
Config {"suffixHarmony": "tr"} Corrects Turkish case suffixes after the address is put back.

Step 2: check what was saved

The guardrail appears as its own card. Nothing uses it yet.

The saved opa-mask card: opa, enforce, both phases, deny and mask, suffixHarmony tr, with a Delete button

Step 3: create a profile

Under Profiles, type ip-masking, tick opa and opa-mask, and press Create profile. Keep opa ticked: a profile replaces the default one, so leaving it out would also switch off your normal policy check for this key.

The Profiles table: default with opa only, ip-masking with opa and opa-mask, assigned to nobody yet

Step 4: give the profile to one key

On Teams & Keys, create an API key for the test (here guardrail-test, in the default team) and copy it; it is shown once. In its row, the second select under Model profile is the guardrail profile: choose guardrails: ip-masking. It saves on change.

The key row: guardrail-test, its prefix, OPA checks on, model profile default and guardrail profile ip-masking

You can give the same profile to a person or a whole team instead. The most specific assignment wins: the person, then the key, then the team, then default.

Step 5: turn the pipeline on

Back on Guardrails, set Pipeline to on. It applies at once, on every replica.

The Pipeline card switched on, set here by the administrator

Part 2 — Try it (with the test key)

Put the key in BOSPHORUS_KEY. The three requests below are the ones that were run; the answers are the ones that came back. They use BT/qwen3-next-80b-instruct, an external model, which is exactly where masking matters. temperature: 0 keeps the answers stable.

Test 1: the model never sees the addresses

curl -s https://ai.corp.example/v1/chat/completions \
  -H "Authorization: Bearer $BOSPHORUS_KEY" \
  -H "Content-Type: application/json" \
  -H "X-GpuPool-Session-Id: ip-masking-test" \
  --data @- <<'EOF' | jq -r '.choices[0].message.content'
{"model": "BT/qwen3-next-80b-instruct", "temperature": 0, "max_tokens": 200,
 "messages": [{"role": "user", "content": "Does the following message begin with a numeric IP address, or with a placeholder token in angle brackets? Reply with exactly one word, IP or PLACEHOLDER. Message: 192.0.2.40 ile 203.0.113.8 haberleşemiyor"}]}
EOF
PLACEHOLDER

The model was looking at <IP_001>.

Test 2: the address comes back, with the right suffix

The model is asked to answer with the first address followed by ’in routing ayarlarını kontrol edin. It only ever has <IP_001>, so that is what it writes.

curl -s https://ai.corp.example/v1/chat/completions \
  -H "Authorization: Bearer $BOSPHORUS_KEY" \
  -H "Content-Type: application/json" \
  -H "X-GpuPool-Session-Id: ip-masking-test" \
  --data @- <<'EOF' | jq -r '.choices[0].message.content'
{"model": "BT/qwen3-next-80b-instruct", "temperature": 0, "max_tokens": 200,
 "messages": [{"role": "user", "content": "Message: 192.0.2.40 ile 203.0.113.8 haberleşemiyor\nTake this template: ADDR'in routing ayarlarını kontrol edin\nReplace ADDR with the first address token of the message, copied exactly as written there. Keep the apostrophe. Output only the resulting sentence."}]}
EOF
192.0.2.40'ın routing ayarlarını kontrol edin

Add "stream": true and the same sentence arrives in pieces. A placeholder split across two pieces (<IP_0 … 01>) is held back until it is whole, so the person never sees half a placeholder.

Test 3: an answer that leaks is withheld

This time the request makes the model write an address of its own, spelled out in words so that nothing in the request can be masked:

curl -s https://ai.corp.example/v1/chat/completions \
  -H "Authorization: Bearer $BOSPHORUS_KEY" \
  -H "Content-Type: application/json" \
  -H "X-GpuPool-Session-Id: ip-masking-test" \
  --data @- <<'EOF'
{"model": "BT/qwen3-next-80b-instruct", "temperature": 0, "max_tokens": 200,
 "messages": [{"role": "user", "content": "Message: 192.0.2.40 ile 203.0.113.8 haberleşemiyor\nWrite this IPv4 address in digits with dots: one nine eight, five one, one zero zero, seven.\nThen reply with exactly this sentence and nothing else, ADDR replaced by that address: Use ADDR as the gateway instead."}]}
EOF
{"error":{"code":403,"message":"response withheld: the model's answer contains 1 raw IP address(es) — an answer to a masked request should carry only placeholders","type":"policy_denied"}}

The model answered Use 198.51.100.7 as the gateway instead. The check runs on the answer while it is still masked, sees an address that is not a placeholder, and the answer is not handed over. Streamed, the same answer is delivered, because the bytes are already on their way, and the hit is recorded instead.

Had the request itself contained 198.51.100.7 in digits, it would have been masked like the others, the model would have echoed a placeholder, and the answer would have passed. That is the guardrail working, not missing.

Part 3 — See what happened (administrator)

Every request is on Activity. Filter it by the session id ip-masking-test and press Flow → on the band: every request shows masked 2 IP among its gateway controls, the withheld one ends in answer withheld, and its streamed twin in would withhold. Open the withheld request:

The request page of the withheld answer: the verdict Answer withheld, the path ending in a red Answer check with pii-unmasked-in-answer, Facts for team default and key guardrail-test, the Policy and guardrails card with opa-mask masking 2 IP findings and the answer check withheld, the conversation, and the model’s answer marked as not received by the client

The article on reading the Activity page explains every part of these views.

Part 4 — Roll back (administrator)

In this order. The first step alone turns it off for everyone.

  1. Guardrails → Pipeline: set it back to inherit, or off.
  2. Teams & Keys: in the key’s row, set the guardrail profile back to guardrails: default. Revoke the test key if you created one for this.
  3. Guardrails → Profiles: Delete ip-masking.
  4. Guardrails: on the opa-mask card, Delete. It is also removed from any profile that still lists it.

The three built-in guardrails, opa, presidio and defenseclaw, cannot be deleted. Set one to off instead.

Things to know

If something does not work

What you see Why, and what to do
The model receives the real addresses The pipeline is not on, or the key does not carry the profile, or the profile does not list opa-mask. Check all three; the key row shows the profile.
The answer shows a placeholder such as <IP_007> The model invented a placeholder the request never minted. Only placeholders the request created are put back; anything else is left as written.
'in was not corrected to 'ın The model wrote the suffix without an apostrophe (<IP_001>in). Suffix harmony only acts on an apostrophe and a suffix it recognises.
Every caller suddenly sees masking mask was added to the built-in opa guardrail or to the default profile. Undo that; use a dedicated guardrail as in Step 1.
503 policy_error The check could not run and the guardrail is set to fail closed. Tick fail open, or find out why the policy engine is unreachable.