Have you ever turned on "Zero Data Retention" in OpenRouter and assumed your prompts were now safe?

Zero Data Retention (ZDR) is a setting that sends your requests only to providers that promise not to store your prompts or the model's answers.

Security firm Dragos tested this. From July to November 2026, they sent about two million prompts to AI providers. Each prompt held a fake password or key that alerted Dragos if anyone used it.

Some of those prompts were sent with ZDR on, so you'd expect no one to ever see the keys inside them. But some of those keys got used. Unknown attackers had broken into three providers and copied the prompts.

This article explains what ZDR does and doesn't protect, how OpenRouter responded, and five guards you can add to protect what ZDR can't.

What ZDR Covers, and What It Doesn't

ZDR is a promise about storage, not protection from attackers. It only sends your prompts to providers that promise not to store them.

But Dragos found that the attacker copied each prompt the moment it arrived at the provider, before it even reached the model. Deleting it afterward didn't matter.

What ZDR promises: the prompt goes to the provider, then the model, then it is deleted. What Dragos found: an attacker copies the prompt at the provider before it reaches the model, so the copy survives the deletion

Dragos also found that a provider that promises ZDR can still pass the prompt on to another company that doesn't. So OpenRouter might send your prompt to a company that promises ZDR, but your prompt could end up with one that doesn't.

Your prompt goes from you to OpenRouter to provider A, which promised ZDR, then to company B, which never promised ZDR, before it reaches the model

How OpenRouter Responded, and What It Doesn't Solve

In response to Dragos's findings, OpenRouter says its own systems were not breached. On November 22, 2026, it posted a few changes for better security, including:

  • Removed 3 unnamed providers from OpenRouter entirely after its own investigation
  • Removed 125 endpoints from the ZDR list because they might not keep the ZDR promise
  • Notified all customers who may have been affected

OpenRouter is also working on three more changes:

  • Regular tests that send fake keys through providers and watch for anyone using them
  • Checks on whether providers pass requests on to other companies
  • Putting the 125 removed endpoints back on the ZDR list only after each one is checked

These changes help, but they can only detect a breach after it happens. So don't rely on OpenRouter alone. The next five sections show five simple guards you can add yourself.

Guard 1: Opt Out of Safety Retention

Even with ZDR on, self-serve accounts still allow Safety Retention by default. It lets a provider keep any prompt to scan for misuse like hacking or weapons questions, but not train on it.

To opt out, follow the ZDR docs to stop allowing Safety Retention. However, some models such as Gemini on Vertex require Safety Retention, so you won't be able to use them once you stop allowing it.

With ZDR on and Safety Retention allowed, the default, your prompt can go to a ZDR provider that doesn't keep it or a Safety Retention provider that may keep it. With Safety Retention not allowed, it only goes to ZDR providers, and Gemini on Vertex becomes unavailable

Guard 2: Allow Only the Providers You Trust

By default, OpenRouter can send your request to any provider that serves the model, which can include providers that you don't trust.

To keep your prompt away from them, list the providers you trust in provider.only. OpenRouter then sends the request only to those providers:

response = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": prompt}],
    extra_body={"provider": {"only": ["azure"]}},
)

To apply the same list to every request made with your API keys, set allowed providers in your privacy settings.

Guard 3: Keep Keys Out of Your Code

If a key is written in your script, it goes into the prompt every time you or a coding agent send that code to a model. Instead, store the key in a .env file or a secret manager, and read it from an environment variable. The prompt then holds only the variable's name, not the key.

Before:

client = OpenAI(api_key="sk-or-v1-abc123def456ghi789")

After:

import os

client = OpenAI(api_key=os.getenv("OPENROUTER_API_KEY"))

Here are two places to keep the key.

Use a .env File

A .env file is a text file that lists environment variables and their values. Store the key in it:

OPENROUTER_API_KEY=sk-or-v1-abc123def456ghi789

Then load it in your code with the python-dotenv package:

import os

from dotenv import load_dotenv

load_dotenv()

client = OpenAI(api_key=os.getenv("OPENROUTER_API_KEY"))

Use a Secret Manager

A .env file helps, but it isn't foolproof, since the key is still on your disk, where a coding agent can read it. A secret manager such as Infisical is safer because it keeps the key off your disk entirely.

Once you've set it up, start your app with infisical secrets-manager run to pass the key in as an environment variable:

infisical secrets-manager run -- python app.py

Guard 4: Mask Secrets Before the Prompt Leaves

A .env file keeps the key out of your code, but the key can still reach a prompt. Your app may include a log or error message that prints the key.

If a key does end up in a prompt, masking replaces it with a label such as [secret: OPENROUTER_API_KEY], so the real value never reaches OpenRouter.

It can be tricky to find secrets in a prompt. Let's walk through three ways to find them.

Find Values Named Like Secrets

Let's say your app sends this error log to a model:

ERROR: failed to start, config was:
OPENROUTER_API_KEY=sk-or-v1-abc123def456ghi789
SESSION_TOKEN=tok_8f3k2m9x7q4w
JWT_SECRET=s3cr3t-signing-k3y
DB_PASSWORD=Sup3rS3cret!

Secret names often end in KEY, TOKEN, SECRET, or PASSWORD. We can find each name with one of these endings and mask the value after it.

Three steps to mask secrets by their names: the rule is a name ending in KEY, TOKEN, SECRET, or PASSWORD followed by =, the prompt contains OPENROUTER_API_KEY=sk-or-v1-abc and DB_PASSWORD=Sup3rS3cret!, and each value is replaced with a label, secret: OPENROUTER_API_KEY and secret: DB_PASSWORD

If you already keep your secrets in one place, such as a .env file or a secret manager, mask their values in the prompt.

Find Known Key Formats

What if a secret doesn't have a name ending in KEY, TOKEN, SECRET, or PASSWORD?

Another way to find secrets is to look for known key formats. AWS access keys, for example, start with AKIA.

You don't need to write these format rules yourself. Betterleaks already has them for AWS, GitHub, OpenAI, OpenRouter, Anthropic, and other common keys.

Three steps to mask a key by its format: the rule is AKIA followed by 16 letters or digits, the prompt contains AKIAIOSFODNN7EXAMPLE, and that text is replaced with the label secret: AWS Access Key

Find Passwords in URLs

Sometimes a URL, such as a database URL, contains a password. The password has no name and no format, but it always sits between user: and @, so a regex can find it.

Three steps to mask a password inside a URL: it sits between user: and @, so in postgresql://admin:Sup3rS3cret!@db the text Sup3rS3cret! is found and replaced with the label secret: password in a URL.

Guard 5: Scan Prompts with a Local Model

Keys aren't the only secrets in a prompt. A prompt can also hold a customer's name or the details of an unreleased product. These have no fixed format, so a regex can't find them.

To find them, scan the prompt with a small local model. Since the model is local, the prompt it reads stays on your machine.

There are two kinds of local models for this.

Use a Model with Fixed Labels

OpenAI Privacy Filter is a small open-weight model that runs on a laptop. It finds personal data and secrets, such as emails, account numbers, and API keys, and replaces each with its label.

Let's say a prompt holds an email and the ship date of an unreleased product called Falcon. OpenAI Privacy Filter replaces the email and the date with its labels.

A model with fixed labels such as private_email, private_date and secret finds jane@acme.com and May 3 in the prompt Email jane@acme.com: Falcon ships May 3, and replaces them with private_email and private_date. Falcon is left as it is

But "Falcon" stays, because Privacy Filter doesn't know your product names are secret, and you can't add new labels to it. To catch secrets like this, use a model that follows rules you write.

Write Your Own Rules

Guard models such as Shieldstral 1.0 3B, Granite Guardian 4.1 8B, and gpt-oss-safeguard-20b read a rule written in plain words, such as "Does this prompt mention our unreleased products, Falcon or Osprey?", and answer yes or no. If the answer is yes, your code blocks the prompt.

A model following the rule Does this prompt mention our unreleased products, Falcon or Osprey? reads Email jane@acme.com: Falcon ships May 3, finds Falcon, and answers yes, so the prompt is blocked

It is best to combine masking with a local model. Masking is fast and exact for keys it knows, while the model is slower but can find secrets with no fixed pattern.

Assume Your Keys Will Leak

Even if you follow all the guards, a key may still leak. To limit the damage, keep the key short-lived and scoped to only the permissions it needs. Dragos saw one stolen key still in use three weeks later.

If a key may have been in a prompt, create a new one and revoke the old one right away. In Dragos's test, attackers tried stolen AWS keys within a few hours.

Final Thoughts

ZDR decides who gets your prompt. It can't stop someone who has already broken into that provider. OpenRouter's response makes breaches less likely, but breaches can still happen.

So assume any prompt can leak, and remove secrets before they leave your machine.

Here's the checklist to protect your prompts:

[ ] Safety Retention no longer allowed
[ ] Only providers you trust are allowed
[ ] Keys live in .env or a secret manager, not in code
[ ] Mask secrets before the prompt leaves your machine
[ ] Scan prompts with a local model for personal data and trade secrets
[ ] Rotate any key that has ever appeared in a prompt
[ ] New keys are short-lived and scoped

These guards lower the risk, but they can't remove it. Masking and local models can both miss a secret. To keep every secret off someone else's servers, send your prompts only to a model on your own machine or network.

References

Share this post

Never miss a post

Benchmarks, deep dives, and lessons from OpenTeams engineers. Get the Engineering newsletter once a month, or follow the feed.

Or subscribe via RSS