> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Moderation Guardrail

> Detect content policy violations using OpenAI's moderation API.

The OpenAI Moderation Guardrail is a built-in guardrail that detects content that violates OpenAI's content policy in the input of your Agents.

This helps you catch violations faster, without firing an API request that would fail anyway.

It can also be useful if you are using a different provider but still want to use the OpenAI Moderation guidelines.

## Usage

To use the OpenAI Moderation Guardrail, you need to import it and pass it to the Agent with the `pre_hooks` parameter:

```python theme={null}
from agno.guardrails import OpenAIModerationGuardrail
from agno.agent import Agent
from agno.models.openai import OpenAIResponses

openai_moderation_guardrail = OpenAIModerationGuardrail()

agent = Agent(
    name="OpenAI Moderation Guardrail Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    pre_hooks=[openai_moderation_guardrail],
)
```

## Moderation model

By default, the OpenAI Moderation Guardrail will use OpenAI's `omni-moderation-latest` model.

You can adjust which model is used for moderation by providing the `moderation_model` parameter:

```python theme={null}
openai_moderation_guardrail = OpenAIModerationGuardrail(
    moderation_model="omni-moderation-latest",
)
```

## Moderation categories

You can specify which categories the guardrail should check for.

By default, the guardrail will consider all the existing moderation categories. You can check the list of categories in [OpenAI's docs](https://developers.openai.com/api/docs/guides/moderation#review-supported-categories).

You can override the default list of moderation categories using the `raise_for_categories` parameter:

```python theme={null}
openai_moderation_guardrail = OpenAIModerationGuardrail(
    raise_for_categories=["violence", "hate"],
)
```

## Developer Resources

* [Examples](/guardrails/usage/agent/openai-moderation)
* [Reference](/reference/hooks/openai-moderation-guardrail)
