メインコンテンツへスキップ
POST
/
v1
/
moderations
curl --request POST \
  --url https://api.apimart.ai/v1/moderations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "omni-moderation-latest",
    "input": [
      {
        "type": "text",
        "text": "この画像が違反していないかモデレーションしてください"
      },
      {
        "type": "image_url",
        "image_url": {
          "url": "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg"
        }
      }
    ],
    "stream": false
  }'
import requests

url = "https://api.apimart.ai/v1/moderations"

payload = {
    "model": "omni-moderation-latest",
    "input": [
        {
            "type": "text",
            "text": "この画像が違反していないかモデレーションしてください"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg"
            }
        }
    ],
    "stream": False
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/moderations";

const payload = {
  model: "omni-moderation-latest",
  input: [
    {
      type: "text",
      text: "この画像が違反していないかモデレーションしてください",
    },
    {
      type: "image_url",
      image_url: {
        url: "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg",
      },
    },
  ],
  stream: false,
};

const headers = {
  Authorization: "Bearer <token>",
  "Content-Type": "application/json",
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));
omni-moderation-latest を使って入力コンテンツの安全モデレーションを行います。本モデルはモデレーションシリーズに属し、画像・動画・音声生成シリーズには含まれません。
curl --request POST \
  --url https://api.apimart.ai/v1/moderations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "omni-moderation-latest",
    "input": [
      {
        "type": "text",
        "text": "この画像が違反していないかモデレーションしてください"
      },
      {
        "type": "image_url",
        "image_url": {
          "url": "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg"
        }
      }
    ],
    "stream": false
  }'
import requests

url = "https://api.apimart.ai/v1/moderations"

payload = {
    "model": "omni-moderation-latest",
    "input": [
        {
            "type": "text",
            "text": "この画像が違反していないかモデレーションしてください"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg"
            }
        }
    ],
    "stream": False
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/moderations";

const payload = {
  model: "omni-moderation-latest",
  input: [
    {
      type: "text",
      text: "この画像が違反していないかモデレーションしてください",
    },
    {
      type: "image_url",
      image_url: {
        url: "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg",
      },
    },
  ],
  stream: false,
};

const headers = {
  Authorization: "Bearer <token>",
  "Content-Type": "application/json",
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));

対応モデル

モデル名説明対応入力
omni-moderation-latest汎用コンテンツモデレーションモデルテキスト・画像・テキスト+画像の混合

Authorizations

Authorization
string
必須
すべてのエンドポイントは Bearer Token による認証が必要です。API Key の取得:API Key 管理ページ にアクセスして API Key を取得してください。リクエストヘッダーに以下を追加します:
Authorization: Bearer YOUR_API_KEY

Body

model
string
必須
モデレーションモデル名。
  • omni-moderation-latest - 汎用コンテンツモデレーションモデル
input
string | string[] | object[]
必須
モデレーション対象のコンテンツ。プレーンテキスト、テキスト配列、コンテンツブロック配列に対応します。コンテンツブロックには以下を含めることができます:
  • text - テキストコンテンツブロック
  • image_url - 画像 URL コンテンツブロック
stream
boolean
デフォルト:"false"
ストリーミングで返すかどうか。
  • false:非ストリーミング応答(デフォルト。現在この値のみサポート、true は非対応)

input のリクエスト方式

テキスト+画像の混合

{
  "model": "omni-moderation-latest",
  "input": [
    {
      "type": "text",
      "text": "この画像が違反していないかモデレーションしてください"
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg"
      }
    }
  ],
  "stream": false
}

プレーンテキスト(単一)

{
  "model": "omni-moderation-latest",
  "input": "I want to kill someone",
  "stream": false
}

プレーンテキスト(配列)

{
  "model": "omni-moderation-latest",
  "input": [
    "hello",
    "I hate you"
  ],
  "stream": false
}

画像のみ(画像 URL)

{
  "model": "omni-moderation-latest",
  "input": [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://cdn.apimart.ai/files/1779955589195-wh950j4imqd.jpeg"
      }
    }
  ],
  "stream": false
}

画像のみ(base64 Data URI)

{
  "model": "omni-moderation-latest",
  "input": [
    {
      "type": "image_url",
      "image_url": {
        "url": "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAA..."
      }
    }
  ],
  "stream": false
}

注意事項

  1. input がコンテンツブロック配列の場合、各要素は type でコンテンツ種別を区別します。
  2. 画像モデレーションは公開アクセス可能な URL を推奨します。base64 を使う場合は標準 Data URI 形式 data:image/{format};base64,{data} に従ってください。
  3. 特別な要件がない限り、stream: false で統一することを推奨します。