Sample - OpenAI API
POST/moderations

Create a content moderation request

Creates a moderation request that classifies text, strings, or multimodal inputs for potentially harmful content. Supply input as a string, an array of strings, or an array of multimodal input objects; model defaults to omni-moderation-latest when omitted.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

2 body fields

Moderation request containing the content to classify and, optionally, the moderation model.

inputstringrequired
Input (or inputs) to classify. Can be a single string, an array of strings, or an array of multi-modal input objects similar to other models.
Default:
modelstringoptional
The content moderation model you would like to use. Learn more in [the moderation guide](https://developers.openai.com/api/docs/guides/moderation), and learn about available models [here](https://developers.openai.com/api/docs/guides/moderation).
Default:omni-moderation-latest

3 status codes
200Returns a moderation result containing the request `id`, the `model` used, and an array of classification results with flags, category results, category scores, and applied input types.
idstringrequired
The unique identifier for the moderation request.
modelstringrequired
The model used to generate the moderation results.
resultsarray<object>required
A list of moderation objects.
429Returned when the request rate exceeds the permitted limit. Reduce the request rate and increase it gradually after traffic stabilizes.

One documented failure

  • slow_down

    Your request rate increased too quickly. Please reduce the request rate and gradually increase it again.

    Traffic increased too quickly

errorobjectrequired
503Returned when the moderation service is temporarily unavailable or the requested model is overloaded. Retry after a brief delay.

One documented failure

  • server_is_overloaded

    The model is temporarily overloaded. Please retry your request after a brief delay.

    The requested model is temporarily overloaded

errorobjectrequired

Error handling

input is required and must be a string, an array of strings, or an array of multimodal input objects. A 429 is returned when the request rate exceeds the limit. A 503 is returned when the requested moderation model is temporarily unavailable or overloaded.