Vercel Logo

How Do I Keep My Prompts Private?

Prompts can contain internal instructions, customer context, support history, or the taco recipe that keeps the lunch line moving.

Privacy belongs in the routing requirements. AI Gateway can remove providers that do not satisfy the policy before the prompt is sent.

Quick Answer

Set disallowPromptTraining: true in providerOptions.gateway to exclude providers without a no-training agreement. Add zeroDataRetention: true when the request also requires an eligible zero-retention policy. Inspect routing.planningReasoning; if no provider qualifies, the request fails with no_providers_available.

Outcome

Send one synthetic sensitive prompt with both privacy controls and verify that the routing plan respected them.

Fast Track

  1. Add both privacy fields under providerOptions.gateway
  2. Run pnpm private-prompts
  3. Verify planningReasoning, or inspect a safe no_providers_available failure

Hands-on exercise

Create scripts/private-prompts.ts. Use synthetic content; privacy controls are not a reason to put real secrets in a course exercise.

scripts/private-prompts.ts
import { generateText } from "ai";
 
const result = await generateText({
  model: "anthropic/claude-sonnet-4.6",
  prompt:
    "Our secret: La Consecuencia gets exactly three ghost peppers, torched, " +
    "never boiled. Draft one sentence warning customers, without the recipe.",
  providerOptions: {
    gateway: {
      disallowPromptTraining: true,
      zeroDataRetention: true,
    },
  },
});
 
const routing = result.finalStep.providerMetadata?.gateway?.routing as any;
 
console.log(result.text.trim());
console.log("---");
console.log(`Served by: ${routing?.finalProvider}`);
console.log(`Routing:   ${routing?.planningReasoning}`);

Try It

Run it:

pnpm private-prompts

A successful answer alone is not proof. Confirm that the output includes the serving provider and planning reasoning. Depending on current model and provider policy, the correct result may instead be no_providers_available. That failure is the privacy control doing its job.

BYOK changes the policy boundary

BYOK traffic runs under your agreement with the provider. Do not assume a Gateway system-credential policy automatically describes retention under your own key. Check the selected model, provider, and credential type together.

The two filters compose. The Gateway should not satisfy one by ignoring the other. Model-specific retention exceptions also exist, so re-check the current policy before sending sensitive production data.

Commit

git commit -m "feat(privacy): require no training and zero data retention"

Done-When

  • Both privacy options are enabled in the request
  • The output includes routing planning metadata, or the request safely fails because no provider qualifies
  • You can explain why a successful answer without routing evidence is insufficient
  • The exercise contains no real secret or customer data

Solution

The script treats privacy requirements as provider filters and keeps routing metadata as evidence. A successful answer without that evidence does not confirm which policy was applied.

Was this helpful?

supported.