Skip to main content

Module request

Module request 

Source
Expand description

OpenAI Moderations API Request Module

This module provides the functionality to interact with the OpenAI Moderations API. It allows you to classify text inputs to determine if they violate content policies.

§Key Features

  • Single Text Moderation: Check a single text string
  • Batch Moderation: Check multiple texts at once
  • Model Selection: Choose between omni-moderation and text-moderation models

§Quick Start

use openai_tools::moderations::request::Moderations;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let moderations = Moderations::new()?;

    // Check a text for policy violations
    let response = moderations.moderate_text("Hello, world!", None).await?;
    if response.results[0].flagged {
        println!("Content was flagged!");
    } else {
        println!("Content is safe");
    }

    Ok(())
}

Structs§

Moderations
Client for interacting with the OpenAI Moderations API.

Enums§

ModerationModel
Moderation model options.