Skip to main content
POST
cURL

Overview

Use POST /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. If you want NanoGPT to run a paid input safety preflight automatically before supported generation requests, use Inline Moderation instead. 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_KEY
  • x-api-key: YOUR_API_KEY

Model Selection

The model 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

Input Examples

Single Text Input

Batch Text Input

Batch support can vary by model. If a selected model does not support batched input, the API returns an error before billing.

Text Content Part

Image Input

Image support depends on the selected model. Text-only models reject image input before billing.

Example

Response

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:

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Parameters for creating a moderation classification

input
required

Content to classify

Example:

"Text to classify for safety."

model
string

Moderation model ID. Omit to use the default moderation model.

Example:

"moderation-model-id"

Response

Moderation classification response

id
string
required

Moderation request identifier

Example:

"modr_..."

model
string
required

Moderation model used for classification

Example:

"moderation-model-id"

results
object[]
required

Moderation results for each classified input

usage
object

Token usage used for billing and diagnostics