Skip to main content

Safety Best Practices

A check is one part of keeping your product safe. These habits make it work well.

Test with tricky inputs​

Before a policy set goes live, try content written to slip past it in the dashboard's Playground:

  • the same thing said indirectly, in another language, or "hypothetically";
  • content that falsely claims an exception applies ("it's for a school project");
  • content close to the line, on both sides.

Reword the rules when something gets through, and keep the cases you find. Rerun them whenever you change the set.

Send the unclear cases to a person​

Route to a person wherever a wrong verdict would be costly. Image checks return unknown when an image can't be judged, and isSafe() treats it as unsafe:

const result = await client.checkImage(file, 'uploads', { showReason: true });
if (!isSafe(result)) {
await reviewQueue.add({ file, verdict: result.verdict, reason: result.reason });
}

Give the reviewer the content, the policy set name and the reason.

Log your own user ID with each check​

We never receive your users' identities. Log your own (hashed) user ID next to each check's verdict, so you can spot one user's repeated abuse later:

const result = await client.checkText(message, 'chat');
await auditLog.write({ user: hashedUserId, policySet: 'chat', verdict: result.verdict });

Keep API keys safe​

  • Keep keys in a secret manager, never in code or in a browser.
  • Use a separate project and key for each environment, so revoking one doesn't break the others.
  • If a key leaks, revoke it on the dashboard's API keys page. It stops working at once.
  • Only save or delete policy sets from your server: they change what every check means.

Let users report mistakes​

Give people a way to say a verdict was wrong, in either direction, and have someone read the reports. Log the content, policy set and verdict so each report can be checked. Reports make good test cases.

Know what a check covers​

  • A check answers one question: does this content break this policy set?
  • Text gets block or pass. Images can also get unknown.
  • Image checks judge only what's visible in the image. Intent, consent and context outside it aren't.