POST/moderations

Create a moderation classification

Classifies text and image inputs for potentially harmful content. Supply input as a string, an array of strings, or supported multimodal input; model defaults to omni-moderation-latest. Use the returned results to review moderation flags, categories, and category scores.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 body fields

Content to classify and, optionally, the moderation model to use.

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

6 status codes
200Returns the moderation request identifier, the model used, and a list of results containing flags, categories, 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.
400Returned when moderation input is invalid or request parameters are unsupported.
errorobjectrequired
403Returned when access to the requested moderation model is denied.
errorobjectrequired
429Returned when the request rate limit is exceeded. A `slow_down` error indicates that traffic increased too quickly.

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
500Returned when an internal error prevents the moderation request from being processed.
errorobjectrequired
503Returned when the service is temporarily unavailable or the requested model is overloaded.

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

A 400 is returned when input is invalid or request parameters are unsupported. A 403 is returned when access to the requested moderation model is denied. A 429 is returned when the request rate limit is exceeded; for a slow_down error, reduce your request rate and increase it gradually. A 500 is returned when an internal error prevents processing, and a 503 is returned when the service or requested model is temporarily unavailable. input is required, and model must be one of omni-moderation-latest, omni-moderation-2024-09-26, text-moderation-latest, or text-moderation-stable when specified.