Skip to main content

Overview

Write your content rules in plain English, once. Then check any text or image against them with one call.

import { Policies, SafetyClient, isSafe } from '@chidakashi-ai/safety';

const creds = { apiKey: process.env.SAFETY_API_KEY! };

// Once, e.g. when you deploy.
await new Policies(creds).save('chat', `
1) No threats of violence against another person.
2) No sharing of someone's home address or phone number.
`);

// On every message.
const client = new SafetyClient(creds);
const result = await client.checkText(message, 'chat');
if (!isSafe(result)) await rejectMessage();
You checkYou get back
Textblock or pass
An imageblock, pass or unknown

There are no built-in categories to pick from. You write the rules your product needs, as specific as you like.

Common uses​

  • Chat and comments: check each message before it's sent or shown. See Moderating chat.
  • Uploads: check a photo before you store it. See Moderating uploads.
  • Around your own AI model: check the user's prompt before it reaches your model, and the model's reply before it reaches the user.

Where it sits​

Your applications and the SDK call Kavach: once to save your policy, then for each turn to check the prompt and the model's response.

Kavach is called from your server. It never sits in front of your model, and your model stays yours. Today, text and image checks are live and the SDK is for Node.

Next​