In-app chat applications require effective moderation systems to manage and regulate user messages, and automatic moderation using machine learning, generative AI, and large language models like GPT-3 and GPT-4 is essential due to the impracticality of human moderation alone. PubNub provides versatile solutions, including PubNub Functions, which can intercept and modify messages while integrating with external services such as OpenAI's Moderation API. This API, which is currently free and supports only English, categorizes harmful content into various categories like hate, harassment, self-harm, and violence. Developers can implement this moderation by creating PubNub Functions that interact with the API, using the "Before Publish or Fire" event type to process messages before delivery. The integration process involves setting up PubNub Functions, providing an OpenAI API key, and updating client applications to handle moderation payloads effectively. The approach allows for real-time moderation and sentiment analysis, enhancing the safety and user experience of chat applications. Additionally, resources and support are available for developers seeking to integrate these tools into their applications.