Quick start

CalmLens tells your app whether user content is safe to show. Pick how content reaches CalmLens. The steps below change to match, and you only need one of them.

How will content reach CalmLens?

Upload from your server

Use this when your backend already receives the content, or when you're moderating text such as comments and messages.

1. Get an API key and your project ID

In Portal › Developer › API Keys, create a key and copy it, then copy the Project ID shown next to it. Store both on your server, for example as CALMLENS_API_KEY and CALMLENS_PROJECT_ID. Never put the key in browser or mobile app code.

npm install @calmlens/sdk
import { CalmLensServerClient } from "@calmlens/sdk/server";

const client = new CalmLensServerClient({
  apiKey: process.env.CALMLENS_API_KEY!,
  projectId: process.env.CALMLENS_PROJECT_ID!,
});

2. Moderate a comment

client.text.moderate() waits for the decision before your app continues.

const result = await client.text.moderate({ text: comment.body, externalId: `comment-${comment.id}` });

if (result.status === "approved") {
  await publishComment(comment);
} else {
  showError("Your comment wasn't posted because it may break our community guidelines.");
}

3. Moderate an image

client.assets.create() returns an asset ID straight away while moderation runs. Save the ID with the post and keep the post hidden until it's approved.

const asset = await client.assets.create({
  name: file.name,
  content: { data: file, type: file.type }, // a File or Blob; base64 and buffers also work
  externalId: `post-${post.id}`,
});
// asset.status is "pending"; save asset.id with the post

4. Receive the result

In Portal › Webhooks & connectors, subscribe your HTTPS endpoint to asset.classified and asset.failed. Match the event's asset ID to your post, then publish or remove it. See Webhooks.

Read the decision

Your project's moderation policy turns each report into an action. Your app only needs two fields:

statusreport.flaggedWhat your app should do
approvedfalsePublish.
approvedtruePublish, and add it to a review queue. The policy action was alert.
rejectedtrueDon't publish. Tell the author it wasn't posted. The action was hide or purge.
pendingN/AStill being classified. Keep it unpublished and wait.
errorN/AClassification failed. Don't publish; retry or review manually.

Try a rejection safely

Use test inputs to check your rejection flow without uploading real harmful content.

Next steps

Signing in

Signing out

Cookies on CalmLens

We use essential cookies to keep you signed in and the site secure. With your permission, we'll also use functional cookies to remember preferences such as your layout and documentation language, and to offer Google One Tap sign-in. We don't use analytics or advertising cookies. Manage cookies