cURL
Endpoint Examples
Moderations
Classify text and image content for safety
POST
cURL
Documentation Index
Fetch the complete documentation index at: https://docs.nano-gpt.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
UsePOST /api/v1/moderations to classify text, image, or mixed content for safety before you store, display, or send user-generated content to another model endpoint.
The endpoint is synchronous and returns an OpenAI-compatible moderation response shape where practical. It is a paid API feature and bills proportionally to usage with no separate minimum charge.
Endpoint
Authentication
An API key is required.Authorization: Bearer YOUR_API_KEYx-api-key: YOUR_API_KEY
Model Selection
Themodel field is optional. If omitted, NanoGPT uses the default moderation model.
Available input types, batch support, context limits, and pricing depend on the selected model. Use Moderation Models before choosing a model instead of hardcoding capabilities.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | No | Moderation model ID. Omit to use the default moderation model. |
input | string, array, or content parts | Yes | Content to classify. |
Input Examples
Single Text Input
Batch Text Input
Text Content Part
Image Input
Example
Response
| Field | Description |
|---|---|
flagged | true when the selected model classifies the content as unsafe. |
categories | Category-level boolean results. Exact category names are model-dependent. |
category_scores | Category-level confidence scores when available. Exact category names are model-dependent. |
usage | Token usage used for billing and diagnostics. |
Billing
The endpoint is paid and bills proportionally to usage. There is no extra minimum charge. General billing behavior:- Input tokens are billed according to the selected moderation model’s input rate.
- Output tokens may be billed when the selected model returns billable classification output.
- NanoGPT performs a preflight balance check before dispatching the request.
- The final charge is based on measured or estimated usage recorded for the completed request.
- Pricing details are returned by
GET /api/v1/moderation-models.
Rate Limits And Access Controls
The endpoint uses standard NanoGPT API authentication, balance checks, API-key limits, and account/team access controls.- API keys can be subject to model allowlists.
- API keys can be subject to spending and token limits.
- Team billing and team restrictions apply where configured.
- Requests can be rate limited.
Errors
Errors follow the standard NanoGPT/OpenAI-compatible error shape:| Status | Code | Meaning |
|---|---|---|
| 400 | empty_input | The request did not include moderatable text or image content. |
| 400 | unsupported_input_modality | The selected model does not support the submitted input type. |
| 400 | unsupported_batch_input | The selected model does not support batched input. |
| 400 | context_length_exceeded | The input is too large for the selected model. |
| 401 | missing_api_key or invalid_api_key | Authentication failed. |
| 402 | varies | The account does not have enough balance. |
| 403 | paid_features_disabled | Paid API features are disabled for the account. |
| 404 | model_not_found | The requested moderation model does not exist or is unavailable. |
| 429 | rate_limit_exceeded | The caller exceeded a rate limit. |
| 503 | provider_error or similar | The upstream moderation service was temporarily unavailable or returned an invalid response. |
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Parameters for creating a moderation classification
Response
Moderation classification response