How to add NSFW filter to Completion API?

How to filter violated text in completion api?
how can we add filter?
How can I avoid or filter it/?

You could use Langchain’s Moderation method for it.
Check this out:
https://python.langchain.com/en/latest/modules/chains/examples/moderation.html

In addition to what @iamsaiyan suggested, you can also send the prompt to OpenAI’s moderation API endpoint.

1 Like

If I add OpenAI’s moderation API endpoint, will it guarantee me being safe from ban if I use my key for the app I provide to people?

Hi and welcome to the Developer Forum!

It shows you are following the Terms of Service in good faith, but it is not a blanket protection from your end users abusing the service, you should have your own moderation policies in place for public facing applications, a good idea is to use the floating point values that come with the moderation endpoint report and build up your own moderation trigger levels, don’t just rely on the true/false flags.

3 Likes

Generally, if you send the message through moderation and it passes you won’t have any problems sending it on to the chat/completion endpoint.

If you ignore the moderation results and send something on anyway, I don’t think that will protect you.

You can probably feel very safe with respect to the integrity of your account if you use the moderation endpoint and respect its responses.

1 Like