POST /v1/moderations takes OpenAI’s request shape and returns one verdict per input, with the model’s own hazard categories.
The moderation model is Llama-Guard-4-12B. Moderation models answer on this endpoint only, so call them here rather than through /v1/chat/completions.
Example
categories carries the model’s own codes rather than OpenAI’s category names.
Inputs
model is required. input takes one of three forms:
- A string. You get one result.
- A list of strings, up to 32. You get one result per string, in the same order.
- A list of content parts, judged together as one item. Use text parts,
{ "type": "text", "text": "..." }, and at most one image part,{ "type": "image_url", "image_url": { "url": "..." } }. You get one result.
Response
flagged is true when the model judges the input unsafe, and categories names the hazards it identified. Every code is present on every result, true or false. There is no category_scores: Llama Guard 4 returns a verdict, not a score.
Decide on flagged. The model can judge an input unsafe without naming a category it recognizes, so a flagged result can have every category false.
When the input includes an image, the model checks
S1 to S13, so S14 is always false for that result.
What to plan for
- A batch succeeds or fails as a whole. If any item fails, the request returns one error rather than partial results, so every result stays aligned with its input. Items that had already completed were real calls and are still billed.
- Each item counts toward your rate limit. A list of 10 strings uses 10 requests from your key’s per-minute limit.
- An unreadable verdict is an error, never a silent pass. If the model’s reply can’t be read as a verdict, you get a
502rather thanflagged: false. - Only moderation models answer here. Any other model returns
400withcode: "model_not_supported", and the message lists the models that do.
Billing
Each input item is one call to the moderation model, billed on its tokens at the model’s input and output rates. A list of three strings is three calls. Rates are on the model page and inGET /v1/models.
See also
- Model discovery — moderation models have
category: "moderation". - Video generation — screen the prompt you actually send to a generator, not only the one the user typed.