Skip to content

API reference

Moderations

Classify content before or after a user-facing AI action. Treat the result as evidence for your application policy.

How it fits together

  1. 01Classify text against the content-safety categories

Select an action to see its complete inputs, request, response, and status codes.

Classify text against the content-safety categories

POST/v1/moderations
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
inputBodystring | array<value>RequiredConditionalA string, an array of strings, or an array of content parts. Only text parts are accepted; an image part is refused, because no configured route has been qualified to classify one. Batch size and per-item length are bounded by service configuration.
modelBodystringOptionalSupportedPublic logical classifier ID. Optional only while a service default classifier is configured; there is no automatic selection, because a verdict is only meaningful when the caller knows which classifier produced it.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/moderations' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "input": "Text to classify."
}'

Response

{
  "id": "<id>",
  "model": "<value>",
  "results": [
    {
      "flagged": false,
      "categories": {},
      "category_scores": {},
      "category_applied_input_types": {}
    }
  ]
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Classify text against the content-safety categories.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.