APIリファレンス
OpenAI Moderations
RunAPIのOpenAI互換Moderationsオペレーションを通じてリクエストを送信します。
01
概要
RunAPIのOpenAI互換のModerations操作を、互換性のあるモデルおよびプロトコルのリクエスト・レスポンス形式とともに使用してください。
クイックスタート
- APIキーを作成し、RUNAPI_API_KEYとして設定します。
- 互換性のあるモデルを選択し、ドキュメントに記載されたパスパラメーターとJSONボディを送信します。
- このオペレーションに示された JSON レスポンスまたはサーバー送信イベントを読み取り、プロトコルエラーを処理してください。
エンドポイント
- ベースURL
https://runapi.ai- コントラクトバージョン
v1- 推奨認証方式
Authorization: Bearer YOUR_API_TOKEN
02
認証情報の送信方法
RunAPIは以下に列挙された各キャリアを受け付けます。生成されたサンプルはプロトコルの推奨ヘッダーを使用します。
- header - 推奨
Authorization: Bearer YOUR_API_TOKEN- header
x-api-key: YOUR_API_TOKEN
03
互換モデル
現在の料金、レート制限、商用利用の詳細については、モデルページを開いてください。
互換モデルを1件表示
04
JSONボディリクエスト仕様
公開プロトコルとRunAPIサポートの両方の証拠があるフィールドのみが記載されています。追加のJSONボディフィールドはそのまま渡されます。
JSON ボディフィールド2件
input["string", "array"]
必須
分類するテキストまたはテキストと画像の混合コンテンツ。
modelstring
任意
RunAPIのモデレーションモデル識別子。デフォルトはomni-moderation-latest。
リクエスト例
JSON
{
"input": [
{
"text": "A peaceful landscape.",
"type": "text"
},
{
"image_url": {
"url": "https://runapi.ai/icon.png"
},
"type": "image_url"
}
]
}
05
HTTP 200
同期レスポンス
スキーマ
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"
}
例
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
HTTP 400
プロトコルエラー: invalid_request
スキーマ
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"
}
例
JSON
{
"error": {
"code": null,
"message": "input is required",
"param": "input",
"type": "invalid_request_error"
}
}
07
生成されたコードサンプル
各cURL、JavaScript、およびPythonのサンプルは、プロトコル固有のSDKを必要とせずに、このコントラクトから検証済みのリクエストを送信します。
インストール
Shell
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())