> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inputapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建内容审核

> 审核单条文本或文本数组。

`POST /v1/moderations`

发送明确的审核模型 `model` 与非空 `input`。本页限定文本和文本数组；模型可见不代表支持审核，图片输入需要另行确认。省略模型时当前实现使用历史默认 `text-moderation-latest`，该名称不保证部署可用。

成功结果为 `results` 数组，按输入顺序读取 `flagged`、`categories` 和 `category_scores`。不要读 `choices` 或期待 SSE；缺少审核结果不能视为通过。分类名及额外字段随上游变化。

审核结果可能受渠道响应格式设置影响，特别是通用文本 `ForceFormat`；详见[内容审核指南与可运行示例](/zh/guides/moderations)。本接口不提供统一免费额度承诺，具体计费以部署配置为准。

[Read in English](/en/api-reference/moderations)


## OpenAPI

````yaml openapi/relay.json POST /v1/moderations
openapi: 3.0.3
info:
  title: API — Core inference API
  version: 0.5.0
  description: >-
    面向接入的精选规范，不是全部管理或供应商接口。 / Curated integration specification, not the entire
    management or provider API.
  license:
    name: AGPL-3.0-or-later
servers:
  - url: https://gateway.example.com
    description: >-
      Example only; replace with your gateway origin and optional path prefix,
      without /v1.
security:
  - BearerAuth: []
paths:
  /v1/moderations:
    post:
      summary: 内容审核 / Moderate content
      description: >-
        精选文本审核契约；ForceFormat 可能移除 results，必须确认渠道设置 / Curated text moderation
        contract; ForceFormat may remove results, so confirm channel settings
      operationId: createModeration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModerationRequest'
      responses:
        '200':
          description: 成功结构仍需检查业务字段 / Check business fields even on HTTP success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModerationResult'
              example:
                id: mod_example
                model: YOUR_MODEL_ID
                results:
                  - flagged: false
                    categories:
                      violence: false
                    category_scores:
                      violence: 0.01
        '400':
          description: 请求参数错误 / Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: 身份校验失败 / Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: 访问被拒绝 / Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: 接口或资源不存在 / Endpoint or resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: 请求被限流或受配额限制 / Rate or quota restriction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: 网关或上游错误 / Gateway or upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 服务暂不可用 / Service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: 其他网关或上游错误；格式可能不同 / Other gateway or upstream error; shape may vary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ModerationRequest:
      type: object
      required:
        - input
      properties:
        model:
          type: string
          description: >-
            显式选择可用审核模型；省略时网关历史默认 text-moderation-latest 不保证可用 / Explicitly
            choose an available moderation model; the gateway historical default
            text-moderation-latest may be unavailable
        input:
          oneOf:
            - type: string
              minLength: 1
            - type: array
              minItems: 1
              items:
                type: string
                minLength: 1
          description: >-
            本规范覆盖文本与文本数组；不承诺全渠道多模态审核 / This specification covers text and text
            arrays, not universal multimodal moderation
    ModerationResult:
      type: object
      required:
        - results
      properties:
        id:
          type: string
        model:
          type: string
        results:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - flagged
              - categories
              - category_scores
            properties:
              flagged:
                type: boolean
                description: 总体审核信号 / Overall moderation signal
              categories:
                type: object
                additionalProperties:
                  type: boolean
                description: 分类键由模型决定 / Category keys depend on the model
              category_scores:
                type: object
                additionalProperties:
                  type: number
                  minimum: 0
                  maximum: 1
                description: >-
                  分类置信评分，不是跨模型统一阈值 / Category confidence scores, not universal
                  cross-model thresholds
              category_applied_input_types:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
                description: 上游可选输入类型说明 / Optional upstream input-type details
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
              nullable: true
            code:
              nullable: true
              description: 错误标识；类型随上游变化 / Error identifier; type varies by upstream
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 模型调用 API Key，不是控制台登录凭据 / Model API key, not console login credentials

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.