View Source ExOpenAI.Moderations (ex_openai.ex v1.8.0)

Modules for interacting with the moderations group of OpenAI APIs

API Reference: https://platform.openai.com/docs/api-reference/moderations

Summary

Functions

Classifies if text and/or image inputs are potentially harmful. Learn more in the moderation guide.

Functions

Link to this function

create_moderation(input, opts \\ [])

View Source
@spec create_moderation([map()] | [String.t()] | String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  model:
    (:"text-moderation-stable"
     | :"text-moderation-latest"
     | :"omni-moderation-2024-09-26"
     | :"omni-moderation-latest")
    | String.t(),
  stream_to: (... -> any()) | pid()
) :: {:ok, ExOpenAI.Components.CreateModerationResponse.t()} | {:error, any()}

Classifies if text and/or image inputs are potentially harmful. Learn more in the moderation guide.

Endpoint: https://api.openai.com/v1/moderations

Method: POST

Docs: https://platform.openai.com/docs/api-reference/moderations


Required Arguments:

  • input: Input (or inputs) to classify. Can be a single string, an array of strings, or an array of multi-modal input objects similar to other models.

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • model: "The content moderation model you would like to use. Learn more in\nthe moderation guide, and learn about\navailable models here.\n"

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"