Enabling Moderation

Add Helicone-Moderations-Enabled: true to your request headers to activate OpenAI moderation.

Moderation Process and How It Works

  1. Activation: When Helicone-Moderations-Enabled is true and the provider is OpenAI, the user’s latest message is prepared for moderation before any chat completion request.

  2. Moderation Check: Our proxy sends the message to the OpenAI Moderation endpoint to assess its content.

  3. Flag Evaluation: If the moderation endpoint flags the message as inappropriate or harmful, an error response is generated:

    {
      "success": false,
      "error": {
        "code": "PROMPT_FLAGGED_FOR_MODERATION",
        "message": "The given prompt was flagged by the OpenAI Moderation endpoint.",
        "details": "See your Helicone request page for more info: https://www.helicone.ai/requests?[REQUEST_ID]"
      }
    }
    

If the message is flagged, the response will have a 400 status code. It’s crucial to handle this response appropriately.

If the message is not flagged, the proxy forwards it to the chat completion endpoint, and the process continues as normal.

Using Your API Key

The moderation call to the OpenAI endpoint will utilize your provided OpenAI API key.

Future Enhancements

We’re continually expanding our moderation features. Upcoming updates include:

  • Customizable moderation criteria