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
Select an action to see its complete inputs, request, response, and status codes.
Classify text against the content-safety categories
POST
/v1/moderationsProduction base URL
https://api.mahvashai.irAuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content type
application/jsonParameters
The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.
| Name | Location | Type | Required | Support | Details |
|---|---|---|---|---|---|
Idempotency-Key | Header | string | Optional | Supported | Replay key for an admitted run; a repeat returns the first result. |
X-Request-ID | Header | string | Optional | Mahvash extension | Client-supplied correlation ID. Echoed on every response; replaced when absent or malformed. |
X-Mahvash-Project | Header | string | Optional | Mahvash extension | Project slug or ID within the caller's organization. Narrows the request principal; it can never widen it. |
input | Body | string | array<value> | Required | Conditional | A 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. |
model | Body | string | Optional | Supported | Public 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
| HTTP | Details |
|---|---|
| 200 | Classify text against the content-safety categories. |
| 400 | The request is not valid. |
| 401 | Authentication credentials are missing or invalid. |
| 402 | The account cannot authorize the request cost. |
| 403 | The principal is not allowed to perform this request. |
| 404 | No such resource is visible to this principal. |
| 409 | The requested transition conflicts with durable resource state. |
| 429 | A quota or rate limit was exceeded. |
| 500 | An internal error occurred. |
| 502 | The selected provider returned an invalid or failed response. |
| 503 | A dependency is temporarily unavailable. |