OpenAI | Moderation

Given an input text, outputs if the model classifies it as violating OpenAI's content policy.

 

Simple Example

Moderate the following text

 


OpenAI := TsgcHTTP_API_OpenAI.Create(nil);
OpenAI.OpenAIOptions.ApiKey := 'API_KEY';
 
WriteLn(OpenAI._CreateModeration('I want to kill them.'));

 

Advanced Example

Moderate the following text choosing the model.

 


OpenAI := TsgcHTTP_OpenAI_JSON.Create(nil);
OpenAI.OpenAIOptions.ApiKey := 'API_KEY';
 
oRequest := TsgcOpenAIClass_Request_Moderation.Create;
Try
  oRequest.Model := 'text-moderation-latest';
  oRequest.Input := 'I want to kill them.';
  oResponse := OpenAI.CreateModeration(oRequest);
   
  if Length(oResponse.results) > 0 then
    WriteLn(oResponse.results[0].flagged);
Finally
  oRequest.Free;
  oResponse.Free;
End;