Quickstart

Create a key, send your first request, and act on the outcome.

Send your first moderation request in a few minutes. You need a Clusterbot account and a server-side environment that can make HTTPS requests.

1. Create an API key

Create an account, verify your email, and open Portal → API keys. Name the key after the application that will use it, then select Create key.

The secret is shown once. Store it in your secret manager, and expose it to your application as an environment variable:

export CLUSTERBOT_BASE_URL="https://your-clusterbot-host"
export CLUSTERBOT_API_KEY="cb_…"

Keep keys on your server. Never ship them in browser code, mobile apps, or URLs, and never commit them. If you export a key in a terminal for testing, clear it from your shell history afterwards. See Authentication for rotation and revocation.

2. Send a request

Post the text you want to classify to POST /v1/moderations:

curl "$CLUSTERBOT_BASE_URL/v1/moderations" \
  -H "X-Api-Key: $CLUSTERBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"You are a wonderful person."}'
using System.Net.Http.Json;

using var client = new HttpClient
{
    BaseAddress = new Uri(Environment.GetEnvironmentVariable("CLUSTERBOT_BASE_URL")!)
};
client.DefaultRequestHeaders.Add("X-Api-Key",
    Environment.GetEnvironmentVariable("CLUSTERBOT_API_KEY"));

using var response = await client.PostAsJsonAsync("/v1/moderations",
    new { content = "You are a wonderful person." });
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const response = await fetch(`${process.env.CLUSTERBOT_BASE_URL}/v1/moderations`, {
  method: "POST",
  headers: {
    "X-Api-Key": process.env.CLUSTERBOT_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ content: "You are a wonderful person." }),
});
if (!response.ok) throw new Error(`Moderation failed: ${response.status}`);
console.log(await response.json());
import os
import requests

response = requests.post(
    f"{os.environ['CLUSTERBOT_BASE_URL']}/v1/moderations",
    headers={"X-Api-Key": os.environ["CLUSTERBOT_API_KEY"]},
    json={"content": "You are a wonderful person."},
    timeout=30,
)
response.raise_for_status()
print(response.json())

A successful call returns HTTP 200:

{
  "flagged": false,
  "categories": [],
  "latencyMs": 74.18,
  "outcome": "Pass",
  "evaluatedBy": "Model"
}

3. Act on the outcome

Branch on outcome, not on flagged. It has three values:

Outcome Meaning Typical action
Pass No criterion reached your review threshold. Publish the content.
FlaggedForReview At least one criterion needs a human decision. Only returned when manual review is enabled. Hold the content and wait for the decision.
Rejected At least one criterion reached your rejection threshold. Block the content or ask the author to edit it.

Rejected content still returns HTTP 200. Your application decides how to enforce the result.

switch (result.outcome) {
  case "Pass":
    await publish(message);
    break;
  case "FlaggedForReview":
    await holdForReview(message, result.reviewId);
    break;
  default: // "Rejected", and any value added in the future
    await reject(message, result.categories);
}

Handle errors explicitly. A failed request — such as 503 provider_unavailable — is not a safe result. Decide whether to retry, queue, or hold the content. See Errors.

4. Tune and monitor

  • Open Portal → Playground to test representative messages and set review and rejection thresholds per category. See Outcomes and thresholds.
  • Open Portal → Usage & activity to follow credit consumption, outcomes, and latency.
  • Call GET /v1/usage from your application to check remaining credits. See Credits, quotas, and rate limits.

Next steps

Questions about this guide? Contact us or try requests in the playground.