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.
Outcome
Send one synthetic sensitive prompt with both privacy controls and verify that the routing plan respected them.
Fast Track
- Add both privacy fields under
providerOptions.gateway - Run
pnpm private-prompts - Verify
planningReasoning, or inspect a safeno_providers_availablefailure
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.
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-promptsA 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.
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.
Related Questions
Was this helpful?