Skip to main content
Live

Text Safety

Check any text against a policy set: chat messages, comments, bios, support tickets, or your AI model's prompts and replies.

const result = await client.checkText(message, 'chat', { showReason: true });
if (!isSafe(result)) await reject(result.reason);

Options​

OptionDefaultWhat it does
showReasonfalseWhen true, the result includes reason, saying which rule was broken. Checks are slower with it on, so leave it off when you only need the verdict.

What you get back​

verdictMeaning
blockThe text breaks at least one rule in the set.
passIt breaks none.

Examples​

Real results for this policy set:

await policies.save('chat', `
1) No threats of violence against another person.
2) No sharing of someone's phone number, email or home address.
3) Heated disagreement and insults about ideas are fine, as long as they are not a threat.
`);
block
“If you show up at the meetup again I will break your legs.”

Rule 1: no threats of violence.

block
“He lives at 22 Elm Street, the blue house. Pay him a visit.”

Rule 2: no sharing someone’s address.

pass
“This is the dumbest take on tax policy I have read all year.”

An insult about an idea, which rule 3 allows.

pass
“I’d love to kill it at the talent show tonight!”

“Kill” here isn’t a threat.

Limits​

Only the first 8,000 characters of the text are checked. Split longer text and check each part.

See also: Moderating chat.