curl -fsSL https://getstream.io/cli.sh | bash
getstream skillsGetting Started
Stream's Moderation API lets you integrate content moderation into any application. This guide walks you through installing one of the backend SDKs, configuration, and your first moderation check.
Moderation lives in the Stream Dashboard, where you can create and tune policies, manage AI rules and blocklists, and review flagged content across your app.
Start here
Stream CLI and Agent Skills
Manage moderation from your terminal with the Stream CLI, including scripting policy setup and AI-agent workflows. Install the CLI and the default Agent Skills:
Then ask your agent in plain English, for example:
/stream Show flagged content in the review queue.See the CLI docs and Agent Skills docs for more.
Installation
Add to your build.gradle:
dependencies {
implementation 'io.getstream:stream-sdk-java:7.+'
}Or Maven pom.xml:
<dependency>
<groupId>io.getstream</groupId>
<artifactId>stream-sdk-java</artifactId>
<version>7.0.0</version>
</dependency>Initialize the client
import io.getstream.services.framework.StreamSDKClient;
var client = StreamSDKClient.builder()
.apiKey("YOUR_API_KEY")
.apiSecret("YOUR_API_SECRET")
.build();Create a moderation policy
Before checking content, create a moderation configuration that defines which rules to apply:
client.moderation()
.upsertConfig(UpsertConfigRequest.builder()
.key("my_config")
.aiTextConfig(AiTextConfig.builder()
.rules(List.of(
AiTextRule.builder().label("SPAM").action("flag").build(),
AiTextRule.builder().label("HARASSMENT").action("remove").build()
))
.build())
.blockListConfig(BlockListConfig.builder()
.rules(List.of(
BlockListRule.builder().name("profanity_en").action("remove").build()
))
.build())
.build())
.execute();For Stream Chat, use config key
chat:messaging. For Stream Feeds, usefeeds. See Configuration for details.
Check content
var response = client.moderation()
.check(CheckRequest.builder()
.entityType("stream:chat:v1:message")
.entityID("message-123")
.entityCreatorID("user-456")
.moderationPayload(ModerationPayload.builder()
.texts(List.of("Hello, this is a test message"))
.build())
.configKey("my_config")
.build())
.execute();
System.out.println(response.getData().getRecommendedAction()); // "keep", "flag", or "remove"Handle the response
The response includes:
getRecommendedAction()--"keep","flag", or"remove"getStatus()--"complete"or"partial"(if async checks are still running)getItem()-- the review queue item (if content was flagged or removed)
The check returns a recommendation for your code to enforce. Stream adds flagged and removed content to the review queue:
flowchart LR
content[User content] --> check[Moderation check]
check --> rec{recommended_action}
rec -->|keep| keep[Your app keeps it]
rec -->|flag| queue[Review queue]
rec -->|remove| removed[Your app removes it]
removed -.->|for audit and appeals| queueString action = response.getData().getRecommendedAction();
switch (action) {
case "keep":
// Content is safe, no action needed
break;
case "flag":
// Content is suspicious; Stream has queued it for review
System.out.println("Flagged for review: " + response.getData().getItem());
break;
case "remove":
// Content violates policies, remove it
System.out.println("Content removed: " + response.getData().getItem());
break;
}