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

# Create moderation

> Classify text inputs for harmful content

Classifies one or more text inputs for harmful content. Schema-compatible with the [OpenAI Moderations API](https://platform.openai.com/docs/api-reference/moderations) — works with the OpenAI SDK.

The response includes standard OpenAI moderation categories as well as [AILuminate](https://ailuminate.mlcommons.org/) safety classifications for more granular signals.


## OpenAPI

````yaml post /v1/moderations
openapi: 3.0.0
info:
  title: Router API
  version: v1
  description: >-
    Intelligent routing and optimization for LLM requests. Automatically selects
    the best model based on your criteria, handles fallbacks, and optimizes for
    cost, latency, or intelligence. Also includes a Router CRUD API for creating
    reusable routing configurations.
servers:
  - url: https://api.inworld.ai
    description: Production server
security:
  - inworld_basic: []
tags:
  - name: Chat Completions
    description: >-
      Main API endpoint for intelligent LLM routing and optimization. Generate
      chat completions with automatic model selection or specific models with
      fallbacks.
  - name: Moderations
    description: >-
      Classify text content for harmful material. Includes OpenAI-compatible
      moderation and conversation-aware chat moderation with AILuminate safety
      signals.
  - name: Router Management
    description: >-
      Service endpoints for creating and managing reusable router
      configurations. Use these to set up routing strategies that can be
      referenced in Chat Completions requests.
paths:
  /v1/moderations:
    post:
      tags:
        - Moderations
      summary: Create moderation
      description: >-
        Classifies one or more text inputs for harmful content.
        Schema-compatible with the OpenAI Moderations API — works with the
        OpenAI SDK.
      operationId: createModeration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModerationRequest'
            examples:
              Single input:
                summary: Single text input
                value:
                  input: Hello world!
              Multiple inputs:
                summary: Array of text inputs
                value:
                  input:
                    - first text to moderate
                    - second text
                    - third text
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModerationResponse'
              examples:
                Single input:
                  summary: Single input result
                  value:
                    id: modr-5cf388daeb3a41b9803fe73f4345a5c3
                    model: inworld/moderation-latest
                    results:
                      - flagged: false
                        categories:
                          sexual: false
                          sexual/minors: false
                          harassment: false
                          harassment/threatening: false
                          hate: false
                          hate/threatening: false
                          illicit: false
                          illicit/violent: false
                          self-harm: false
                          self-harm/intent: false
                          self-harm/instructions: false
                          violence: false
                          violence/graphic: false
                        category_scores:
                          sexual: 0
                          sexual/minors: 0
                          harassment: 0
                          harassment/threatening: 0
                          hate: 0
                          hate/threatening: 0
                          illicit: 0
                          illicit/violent: 0
                          self-harm: 0
                          self-harm/intent: 0
                          self-harm/instructions: 0
                          violence: 0
                          violence/graphic: 0
                        category_applied_input_types:
                          sexual:
                            - text
                          sexual/minors:
                            - text
                          harassment:
                            - text
                          harassment/threatening:
                            - text
                          hate:
                            - text
                          hate/threatening:
                            - text
                          illicit:
                            - text
                          illicit/violent:
                            - text
                          self-harm:
                            - text
                          self-harm/intent:
                            - text
                          self-harm/instructions:
                            - text
                          violence:
                            - text
                          violence/graphic:
                            - text
                        ailuminate:
                          safety: safe
                          categories:
                            violent_crimes: false
                            sex_related_crimes: false
                            child_sexual_exploitation: false
                            suicide_self_harm: false
                            indiscriminate_weapons: false
                            intellectual_property: false
                            defamation: false
                            non_violent_crimes: false
                            hate: false
                            specialized_advice: false
                            privacy: false
                            sexual_content: false
                          extensions:
                            politically_sensitive: false
                            unethical_acts: false
                            jailbreak: false
                          refusal: false
        '400':
          description: Bad request - Missing or invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            text/plain:
              schema:
                type: string
                example: Unauthorized
      security:
        - inworld_bearer: []
      x-codeSamples:
        - lang: bash
          label: Single input
          source: |-
            curl -X POST 'https://api.inworld.ai/v1/moderations' \
              -H 'Authorization: Bearer $INWORLD_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "input": "Hello world!"
              }'
        - lang: bash
          label: Multiple inputs
          source: |-
            curl -X POST 'https://api.inworld.ai/v1/moderations' \
              -H 'Authorization: Bearer $INWORLD_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "input": ["first text to moderate", "second text", "third text"]
              }'
        - lang: python
          label: Python (OpenAI SDK)
          source: |-
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.inworld.ai/v1",
                api_key="YOUR_INWORLD_API_KEY"
            )

            # Single input
            response = client.moderations.create(
                input="Hello world!"
            )
            print(response.results[0].flagged)

            # Multiple inputs
            response = client.moderations.create(
                input=["first text", "second text", "third text"]
            )
            for result in response.results:
                print(result.flagged)
        - lang: javascript
          label: JavaScript (OpenAI SDK)
          source: |-
            import OpenAI from 'openai';

            const client = new OpenAI({
              baseURL: 'https://api.inworld.ai/v1',
              apiKey: 'YOUR_INWORLD_API_KEY',
            });

            // Single input
            const response = await client.moderations.create({
              input: 'Hello world!',
            });
            console.log(response.results[0].flagged);

            // Multiple inputs
            const multi = await client.moderations.create({
              input: ['first text', 'second text', 'third text'],
            });
            multi.results.forEach(r => console.log(r.flagged));
components:
  schemas:
    ModerationRequest:
      type: object
      required:
        - input
      properties:
        input:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: >-
            A single string or an array of strings to classify for harmful
            content.
        model:
          type: string
          description: The moderation model to use.
          default: inworld/moderation-latest
    ModerationResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the moderation request.
        model:
          type: string
          description: The model used for classification.
        results:
          type: array
          description: Array of moderation results, one per input.
          items:
            $ref: '#/components/schemas/ModerationResult'
    ErrorResponse:
      type: object
      description: >-
        Error response format varies: error can be a string or an object with
        message.
      properties:
        error:
          oneOf:
            - type: string
              description: Error message string.
              example: model field is required
            - type: object
              properties:
                message:
                  type: string
                  example: 'Invalid service provider: SERVICE_PROVIDER_INVALID'
    ModerationResult:
      type: object
      properties:
        flagged:
          type: boolean
          description: Whether the content was flagged as harmful.
        categories:
          type: object
          description: Boolean flags for each safety category.
          properties:
            sexual:
              type: boolean
            sexual/minors:
              type: boolean
            harassment:
              type: boolean
            harassment/threatening:
              type: boolean
            hate:
              type: boolean
            hate/threatening:
              type: boolean
            illicit:
              type: boolean
            illicit/violent:
              type: boolean
            self-harm:
              type: boolean
            self-harm/intent:
              type: boolean
            self-harm/instructions:
              type: boolean
            violence:
              type: boolean
            violence/graphic:
              type: boolean
        category_scores:
          type: object
          description: Numeric confidence scores (0–1) for each safety category.
          properties:
            sexual:
              type: number
            sexual/minors:
              type: number
            harassment:
              type: number
            harassment/threatening:
              type: number
            hate:
              type: number
            hate/threatening:
              type: number
            illicit:
              type: number
            illicit/violent:
              type: number
            self-harm:
              type: number
            self-harm/intent:
              type: number
            self-harm/instructions:
              type: number
            violence:
              type: number
            violence/graphic:
              type: number
        category_applied_input_types:
          type: object
          description: Input types evaluated for each category.
          additionalProperties:
            type: array
            items:
              type: string
        ailuminate:
          $ref: '#/components/schemas/AILuminateResult'
    AILuminateResult:
      type: object
      description: >-
        Additional safety classifications based on the AILuminate benchmark by
        MLCommons. Extends the standard OpenAI moderation categories with more
        granular signals.
      properties:
        safety:
          type: string
          description: Overall safety assessment.
          enum:
            - safe
            - unsafe
            - controversial
        categories:
          type: object
          description: Boolean flags for AILuminate-specific safety categories.
          properties:
            violent_crimes:
              type: boolean
            sex_related_crimes:
              type: boolean
            child_sexual_exploitation:
              type: boolean
            suicide_self_harm:
              type: boolean
            indiscriminate_weapons:
              type: boolean
            intellectual_property:
              type: boolean
            defamation:
              type: boolean
            non_violent_crimes:
              type: boolean
            hate:
              type: boolean
            specialized_advice:
              type: boolean
            privacy:
              type: boolean
            sexual_content:
              type: boolean
        extensions:
          type: object
          description: Additional classification signals.
          properties:
            politically_sensitive:
              type: boolean
            unethical_acts:
              type: boolean
            jailbreak:
              type: boolean
        refusal:
          type: boolean
          description: Whether the content represents a refusal.
  securitySchemes:
    inworld_basic:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your [authentication](../../../api-reference/introduction) credentials.
        For Basic authentication, please populate `Basic $INWORLD_API_KEY`.


        Please make sure your API Key has [write permissions for the Router
        API](/api-reference/introduction#getting-an-api-key) in order to create,
        update, and delete routers. You can create a key in one command with the
        [Inworld CLI](../../../tts/resources/inworld-cli): `inworld workspace
        add-key`.
    inworld_bearer:
      type: http
      scheme: bearer
      description: >-
        Your [authentication](../../../api-reference/introduction) credentials.
        Pass your API key as a Bearer token: `Bearer $INWORLD_API_KEY`. You can
        create a key in one command with the [Inworld
        CLI](../../../tts/resources/inworld-cli): `inworld workspace add-key`.

````