Skip to content
RunAPI Developer Docs
API Reference
API Reference

OpenAI Moderations

Send a request through RunAPI's OpenAI-compatible Moderations operation.

01

Overview

Use RunAPI's OpenAI-compatible Moderations operation with a compatible model and the protocol's request and response shapes.

Quick start

  1. Create an API key and set it as RUNAPI_API_KEY.
  2. Choose a compatible model, then send the documented path parameters and JSON body.
  3. Read the JSON response or server-sent events shown for this operation, and handle protocol errors.

Endpoint

POST /v1/moderations
Base URL
https://runapi.ai
Contract version
v1
Preferred authentication
Authorization: Bearer YOUR_API_TOKEN
02

Authentication carriers

RunAPI accepts each carrier listed below. Generated samples use the protocol's preferred header.

header - Preferred
Authorization: Bearer YOUR_API_TOKEN
header
x-api-key: YOUR_API_TOKEN
03

Compatible models

Open a model page for current pricing, rate limits, and commercial-usage details.

Show 1 compatible model
04

Request contract

JSON body

Only fields with both public protocol and RunAPI support evidence are listed. Additional JSON body fields are passed through.

JSON body2 fields
input["string", "array"]
Required

Text or mixed text and image content to classify.

modelstring
Optional

RunAPI moderation model identifier; defaults to omni-moderation-latest.

Request example

JSON
{
  "input": [
    {
      "text": "A peaceful landscape.",
      "type": "text"
    },
    {
      "image_url": {
        "url": "https://runapi.ai/icon.png"
      },
      "type": "image_url"
    }
  ]
}
05

Synchronous response

HTTP 200

Schema

JSON
{
  "additionalProperties": true,
  "properties": {
    "id": {
      "minLength": 1,
      "type": "string"
    },
    "model": {
      "minLength": 1,
      "type": "string"
    },
    "results": {
      "items": {
        "additionalProperties": true,
        "properties": {
          "categories": {
            "additionalProperties": true,
            "type": "object"
          },
          "category_applied_input_types": {
            "additionalProperties": true,
            "type": "object"
          },
          "category_scores": {
            "additionalProperties": true,
            "type": "object"
          },
          "flagged": {
            "type": "boolean"
          }
        },
        "required": [
          "flagged",
          "categories",
          "category_scores"
        ],
        "type": "object"
      },
      "minItems": 1,
      "type": "array"
    }
  },
  "required": [
    "id",
    "model",
    "results"
  ],
  "type": "object"
}

Example

JSON
{
  "id": "modr_123",
  "model": "omni-moderation-latest",
  "results": [
    {
      "categories": {
        "sexual": false,
        "violence": false
      },
      "category_applied_input_types": {
        "sexual": [
          "text",
          "image"
        ],
        "violence": [
          "text",
          "image"
        ]
      },
      "category_scores": {
        "sexual": 0.0002,
        "violence": 0.0001
      },
      "flagged": false
    }
  ]
}
06

Protocol error: invalid_request

HTTP 400

Schema

JSON
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}

Example

JSON
{
  "error": {
    "code": null,
    "message": "input is required",
    "param": "input",
    "type": "invalid_request_error"
  }
}
07

Generated Code Samples

Each cURL, JavaScript, and Python sample sends the validated request from this contract without requiring a protocol-specific SDK.

CURL
curl -X POST https://runapi.ai/v1/moderations \
  -H Authorization:\ Bearer\ YOUR_API_TOKEN \
  -H Content-Type:\ application/json \
  -d \{\"input\":\[\{\"type\":\"text\",\"text\":\"A\ peaceful\ landscape.\"\},\{\"type\":\"image_url\",\"image_url\":\{\"url\":\"https://runapi.ai/icon.png\"\}\}\]\}
JAVASCRIPT
const response = await fetch("https://runapi.ai/v1/moderations", {
  method: "POST",
  headers: {
  "Authorization": "Bearer YOUR_API_TOKEN",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "input": [
    {
      "type": "text",
      "text": "A peaceful landscape."
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "https://runapi.ai/icon.png"
      }
    }
  ]
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data);

Install

BASH
pip install requests
PYTHON
import requests

response = requests.post(
    "https://runapi.ai/v1/moderations",
    headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
    json={"input": [{"type": "text", "text": "A peaceful landscape."}, {"type": "image_url", "image_url": {"url": "https://runapi.ai/icon.png"}}]}
)
response.raise_for_status()
print(response.json())