# Getting Started

Stream's Moderation API lets you integrate content moderation into any application. This guide walks you through installation, configuration, and your first moderation check.

## Installation

```bash
gem install getstream-ruby
```

Or add to your `Gemfile`:

```ruby
gem 'getstream-ruby'
```

## Initialize the Client

```ruby
require "getstream_ruby"

client = GetStream::Client.new(api_key: "YOUR_API_KEY", api_secret: "YOUR_API_SECRET")
```

## Create a Moderation Policy

Before checking content, create a moderation configuration that defines which rules to apply:

```ruby
client.moderation.upsert_config(
  GetStream::Generated::Models::UpsertConfigRequest.new(
    key: "my_config",
    ai_text_config: GetStream::Generated::Models::AiTextConfig.new(
      rules: [
        GetStream::Generated::Models::AiTextRule.new(label: "SPAM", action: "flag"),
        GetStream::Generated::Models::AiTextRule.new(label: "HARASSMENT", action: "remove"),
      ]
    ),
    block_list_config: GetStream::Generated::Models::BlockListConfig.new(
      rules: [
        GetStream::Generated::Models::BlockListRule.new(name: "profanity_en", action: "remove"),
      ]
    )
  )
)
```

> For Stream Chat, use config key `chat:messaging`. For Stream Feeds, use `feeds`. See [Configuration](/moderation/docs/ruby/configuration/policies/) for details.

## Check Content

```ruby
response = client.moderation.check(
  GetStream::Generated::Models::CheckRequest.new(
    entity_type: "stream:chat:v1:message",
    entity_id: "message-123",
    entity_creator_id: "user-456",
    moderation_payload: GetStream::Generated::Models::ModerationPayload.new(
      texts: ["Hello, this is a test message"]
    ),
    config_key: "my_config"
  )
)

puts response.data.recommended_action # "keep", "flag", or "remove"
```

## Handle the Response

The response includes:

- `recommended_action` -- `"keep"`, `"flag"`, or `"remove"`
- `status` -- `"complete"` or `"partial"` (if async checks are still running)
- `item` -- the review queue item (if content was flagged or removed)

```ruby
case response.data.recommended_action
when "keep"
  # Content is safe, no action needed
when "flag"
  # Content is suspicious, send to review queue
  puts "Flagged for review: #{response.data.item}"
when "remove"
  # Content violates policies, remove it
  puts "Content removed: #{response.data.item}"
end
```

## Next Steps

- [Configuration](/moderation/docs/ruby/configuration/policies/) -- Advanced policy setup
- [Stream Chat Integration](/moderation/docs/ruby/integrations/stream-chat/) -- Chat moderation
- [Stream Feeds Integration](/moderation/docs/ruby/integrations/stream-feeds/) -- Feeds moderation
- [Review Queue](/moderation/docs/ruby/content-moderation/review-queue/) -- Query and act on flagged content
- [Client Configuration](/moderation/docs/ruby/guides/client-configuration/) — HTTP defaults, timeouts, and connection pooling


---

This page was last updated at 2026-04-16T18:29:40.334Z.

For the most recent version of this documentation, visit [https://getstream.io/moderation/docs/ruby/](https://getstream.io/moderation/docs/ruby/).