Classify content
Classifies text and images against a moderation model’s categories. The response
carries an id the gateway mints, mdr- followed by 28 random characters; the
model that judged; and results[] with one verdict per moderated item. This
operation returns no usage block.
Requires an API key.
model names a model from Naga’s catalog that serves moderations, and the
gateway selects a provider for it.
input takes one of three shapes: a single string, an array of strings, or an
array of typed parts. A typed part is {"type": "text", "text": …} or
{"type": "image_url", "image_url": {"url": …}}, and the two may be mixed. A
part carrying any other type is refused, with both accepted types named. An
array holds either all strings or all typed parts.
An image url is an http(s) URL or a data: URI carrying the bytes inline.
Any other scheme, including file:, is refused while the body is read. A remote
URL is fetched before the model is called. A URL that cannot be read, or that
exceeds the deployment’s inline-media limit, is refused.
results[] arrives in the order the moderation model returned it and is passed
through unchanged, neither padded to the number of inputs nor trimmed to them.
Each entry carries four fields.
flagged— whether the item tripped any category. This is the model’s own verdict where it sent one, and “any category true” where it sent categories alone.categories— the per-category booleans, in the model’s own order. The key set belongs to that model rather than to a fixed list, so the map is read by key.category_scores— the scores, keyed exactly ascategories.category_applied_input_types— which kinds of input each category was applied to. Present only when the model sends it, and otherwise absent rather thannull.
The account is charged on input tokens alone, at the model’s published prices.
There is no output side to charge. Moderation models report no usage, so the
count is the gateway’s own: text is tokenized here, and every image_url part
costs a flat 250 input tokens regardless of the image.
Every response below 200 carries an object under error with a
machine-readable type, a human-readable message, and, where the failure
concerns one field, param. 429 and 503 carry Retry-After with the
seconds to wait.
Authorizations
An account API key. Send it as Authorization: Bearer <key>.
Body
The request body of POST /v1/moderations.
The moderation model, named by its id or by one of its aliases. A name
this gateway does not serve on this route is refused with 400
model_not_found; a name it served and has since retired, with 410
model_deprecated.
What to moderate. It is billed on tokens counted here rather than
reported by the model: text is tokenized locally, and each image_url
part costs a flat 250 input tokens whatever the image is.
Response
The verdict. results carries one entry per input, each with the flag, the per-category verdicts and the scores behind them.
The body of a successful POST /v1/moderations. It carries no usage
block, unlike the gateway's other non-LLM routes; the request is billed all
the same, on tokens counted here rather than reported by the model.
The identifier of this moderation, minted by the gateway: mdr-
followed by 28 random letters and digits. It is Naga's own and matches
no identifier the upstream may have used.
The model that moderated, as the canonical id the requested name resolved to — an alias sent in the request comes back resolved here. The value is this gateway's catalog name, not anything the provider reported about itself.
The verdicts, in the order the moderation model returned them, normally one per input item. The array is passed through as it came: nothing here pads it out to the number of inputs or trims it to them.