# OpenAIModerationError

> **Class** in `langchain_openai`

📖 [View in docs](https://reference.langchain.com/python/langchain-openai/middleware/openai_moderation/OpenAIModerationError)

Raised when OpenAI flags content and `exit_behavior` is set to ``"error"``.

## Signature

```python
OpenAIModerationError(
    self,
    *,
    content: str,
    stage: ViolationStage,
    result: Moderation,
    message: str,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content` | `str` | Yes | The content that was flagged. |
| `stage` | `ViolationStage` | Yes | The stage where the violation occurred. |
| `result` | `Moderation` | Yes | The moderation result from OpenAI. |
| `message` | `str` | Yes | The error message. |

## Extends

- `RuntimeError`

## Constructors

```python
__init__(
    self,
    *,
    content: str,
    stage: ViolationStage,
    result: Moderation,
    message: str,
) -> None
```

| Name | Type |
|------|------|
| `content` | `str` |
| `stage` | `ViolationStage` |
| `result` | `Moderation` |
| `message` | `str` |


## Properties

- `content`
- `stage`
- `result`

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/6fb37dba71da807af60aa7b909f71f0625a666bf/libs/partners/openai/langchain_openai/middleware/openai_moderation.py#L24)