Quickstart Guide
Make your first text moderation request when MaaS is enabled for your deployment.
Prerequisites
- A CommunitAI account with MaaS access
- An API key (generate one in your dashboard)
- Bun with current Node.js, or standard Python 3.13 or 3.14
Step 1: Get Your API Key
Create an API key from your CommunitAI dashboard. You'll need this to authenticate all requests.
Security: Never expose your API key in client-side code. Always make API calls from your server.
Step 2: Install the SDK
Build the SDK from this repository. Package publication is a separate release step.
bash
# From the CommunitAI repository root
bun install
bun --filter @communitai/maas build
# From your application
bun add /path/to/communitai/packages/maasStep 3: Make Your First Request
Initialize the client and moderate a piece of content:
typescript
import { CommunitAIModerator } from '@communitai/maas';
import { env } from '@/env';
const client = new CommunitAIModerator({
apiKey: env.COMMUNITAI_API_KEY, // Import your application's validated server configuration.
});
const result = await client.moderate({
content: "Hello, this is my first test!",
contentType: "text",
});
console.log(result.decision, result.confidence, result.processingTimeMs);Step 4: Handle the Response
HTTP success responses wrap the decision in { success: true, data: ... }. The SDK returns that data directly. Inspect the actual response; timing, confidence, and model provenance depend on the policies and providers used. A 503 means required moderation could not complete; hold the content and retry later.
typescript
console.log({
requestId: result.requestId,
decision: result.decision,
rulesTriggered: result.rulesTriggered,
processingTimeMs: result.processingTimeMs,
modelVersion: result.modelVersion,
});Decision Values
| Decision | Meaning | Recommended Action |
|---|---|---|
| approve | Content is safe | Allow content to be published |
| reject | Content violates policies | Block content, show violation message |
| warn | Content is borderline | Allow but flag for review |
| review | Needs human review | Queue for manual moderation |