Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Moderation Create Params

From Leeroopedia
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for defining parameters when creating a moderation request provided by the openai-python SDK.

Description

ModerationCreateParams is a TypedDict specifying the parameters for the content moderation endpoint. The required input field accepts a single string, an array of strings, or an array of multi-modal input objects (ModerationMultiModalInputParam). The optional model field selects the content moderation model, accepting either a string or ModerationModel type.

Usage

Import ModerationCreateParams when you need to type-annotate or construct parameters for client.moderations.create().

Code Reference

Source Location

Signature

class ModerationCreateParams(TypedDict, total=False):
    input: Required[Union[str, SequenceNotStr[str], Iterable[ModerationMultiModalInputParam]]]
    model: Union[str, ModerationModel]

Import

from openai.types import ModerationCreateParams

I/O Contract

Fields

Name Type Required Description
input Union[str, SequenceNotStr[str], Iterable[ModerationMultiModalInputParam]] Yes Input(s) to classify. Can be a single string, an array of strings, or an array of multi-modal input objects.
model Union[str, ModerationModel] No The content moderation model to use. See the moderation guide for available models.

Usage Examples

from openai import OpenAI

client = OpenAI()

# Single string input
response = client.moderations.create(input="Text to check for moderation")

# Multiple string inputs
response = client.moderations.create(
    input=["First text to check", "Second text to check"],
    model="omni-moderation-latest",
)

# Check results
for result in response.results:
    print(f"Flagged: {result.flagged}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment