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 Response

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

Overview

Concrete tool for representing the response from a moderation request provided by the openai-python SDK.

Description

ModerationCreateResponse is a Pydantic BaseModel that represents whether given text input is potentially harmful. It contains a unique id for the moderation request, the model string identifying which moderation model was used, and a results list of Moderation objects containing the detailed classification results for each input.

Usage

Import ModerationCreateResponse when you need to type-annotate or inspect the return value from client.moderations.create().

Code Reference

Source Location

Signature

class ModerationCreateResponse(BaseModel):
    id: str
    model: str
    results: List[Moderation]

Import

from openai.types import ModerationCreateResponse

I/O Contract

Fields

Name Type Required Description
id str Yes The unique identifier for the moderation request.
model str Yes The model used to generate the moderation results.
results List[Moderation] Yes A list of Moderation objects with classification details for each input.

Usage Examples

from openai import OpenAI
from openai.types import ModerationCreateResponse

client = OpenAI()

response: ModerationCreateResponse = client.moderations.create(
    input="Some text to moderate"
)

print(f"Request ID: {response.id}")
print(f"Model: {response.model}")
print(f"Number of results: {len(response.results)}")

for i, result in enumerate(response.results):
    print(f"Result {i}: flagged={result.flagged}")

Related Pages

Page Connections

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