<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <link href="https://rockin.ai/blog/generative-ai/?sAtom=1" rel="self" type="application/atom+xml" />
    <author>
        <name>Rockin.AI</name>
    </author>
    <title>Blog/Atom feed</title>
    <id>https://rockin.ai/blog/generative-ai/?sRss=1</id>
    <updated>2026-05-07T10:19:19+02:00</updated>
    
        <entry>
            <title type="text">OpenAI Embeddings Tutorial</title>
            <id>https://rockin.ai/blog/generative-ai/openai-embeddings-tutorial</id>
            <link href="https://rockin.ai/blog/generative-ai/openai-embeddings-tutorial"/>
            <summary type="html">
                <![CDATA[
                
                                            Embeddings help to relate different texts with similar meaning. This new AI capability will change several tech industries.
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 OpenAI embeddings present a new way to describe texts, so that those texts can be ranked or classified based on their meaning. This is a new technology bound to change how we work with text data today. 
 To give a concrete example, most current solutions search for substrings or keywords. With embeddings we can search for  semantic meaning , and not just syntax. 
 In the following tutorial, we will use embeddings to search and rank texts based on their natural language meaning, and provide code samples along the way. Also, we will not be using any fancy tools, and just stick to the basics so that anyone can follow along. 
 &amp;nbsp; 
 What Are Embedding Vectors and Vector Databases? 
 An embedding vector is just a list of decimal values, which describe a given text. For example, the word &quot; Dog &quot; may be represented as [1.5, 2.3, 3.8], which may seem meaningless at first glance. The vector starts to make sense if we compare it to another vector for &quot; Canine &quot;, which may be [1.5, 2.2, 3.7]. Notice how the two vectors are very similar even though the texts are nothing like each other. 
 OpenAI gives us vectors (or just lists of decimal values), which are all of the same size:   1536  values . These vectors capture the meaning of the texts. 
 A vector database is a collection of texts, with their vectors stored in a database table, such as MySQL. This database can later be used ot quickly search or rank results based on a search query. 
 &amp;nbsp; 
 OpenAI Simple Embeddings Client 
 Below is a simple API client for OpenAI&#039;s embeddings function. We will use it later to get embedding vectors for our database and also for our search query. 
 The entire concept only needs a single API endpoint from OpenAI:  /embeddings  
  Side note: &amp;nbsp;please remember to sanitize your text input through  OpenAI moderations in a production setting . 
  
&amp;lt;?php
class OpenAIEmbeddingSimpleClient {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static $open_ai_key = &#039;&amp;lt;your openai key here&amp;gt;&#039;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static $open_ai_url = &#039;https://api.openai.com/v1&#039;; //current version of the API endpoint
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public static function embeddings($text, $model=&#039;text-embedding-ada-002&#039;) { 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//create message to post
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message = new stdClass();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message -&amp;gt; input = $text;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message -&amp;gt; model = $model;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result = self::_sendMessage(&#039;/embeddings&#039;, json_encode($message));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $result;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static function _sendMessage($endpoint, $data = &#039;&#039;, $method = &#039;post&#039;, $contentType = &#039;application/json&#039;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$apiEndpoint = self::$open_ai_url.$endpoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$curl = curl_init();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if($method == &#039;post&#039;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$params = array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_URL =&amp;gt; $apiEndpoint,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYHOST =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_RETURNTRANSFER =&amp;gt; true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_MAXREDIRS =&amp;gt; 10,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_TIMEOUT =&amp;gt; 90,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTP_VERSION =&amp;gt; CURL_HTTP_VERSION_1_1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_CUSTOMREQUEST =&amp;gt; &quot;POST&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_NOBODY =&amp;gt; false, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTPHEADER =&amp;gt; array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;content-type: &quot;.$contentType,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;accept: application/json&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;authorization: Bearer &quot;.self::$open_ai_key
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_setopt_array($curl, $params);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else if($method == &#039;get&#039;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$params = array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_URL =&amp;gt;  $apiEndpoint . ($data!=&#039;&#039;?(&#039;?&#039;.$data):&#039;&#039;),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYHOST =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_RETURNTRANSFER =&amp;gt; true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_MAXREDIRS =&amp;gt; 10,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_TIMEOUT =&amp;gt; 90,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTP_VERSION =&amp;gt; CURL_HTTP_VERSION_1_1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_CUSTOMREQUEST =&amp;gt; &quot;GET&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_NOBODY =&amp;gt; false, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTPHEADER =&amp;gt; array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;content-type: &quot;.$contentType,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;accept: application/json&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;authorization: Bearer &quot;.self::$open_ai_key
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_setopt_array($curl, $params);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$response = curl_exec($curl);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_close($curl);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$data = json_decode($response, true);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!is_array($data)) return array();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $data;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
 
 
 &amp;nbsp; 
 Fetching Vectors and Storing Them In Our Database 
 First, let&#039;s create a MySQL database table, where we will store our texts and vectors. 
  
CREATE TABLE `vectors` (
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;`text` TEXT NULL DEFAULT NULL,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;`embedding` TEXT NULL DEFAULT NULL,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PRIMARY KEY (`id`) USING BTREE
)
ENGINE=InnoDB;
 
 
 &amp;nbsp;Then, using the above API client, we can connect to OpenAI, and create our vector database, which looks like the following: 
   
 &amp;nbsp; 
 We use the   `embedding`   column with type TEXT to store the vectors as plain text, however in a production setting we would probably use a BLOB and store the values as 8 byte floating point values. This would greatly increase efficiency, and would also reduce our database size by a factor of 3. However, we can get good performance even with this naive approach. 
 It is worth noting there are other tools available, which can manage vectors natively - but these normally come with a price tag. 
  &amp;nbsp;  
 How Much Does The OpenAI Embeddings API Cost? 
 OpenAI charges&amp;nbsp;$0.0001 per 1K tokens, and 1K tokens are roughly 4k characters of text. To put this in perspective, it would cost just&amp;nbsp; two cents  to get embeddings for a 100 page book. 
 This is also a one-time cost, which does not have to be repeated if the embeddings are stored in a database. If your texts start to get too long,  consider using text rephrasing capabilities . 
 &amp;nbsp; 
 Example Code For Searching Our Vector Database 
 Below is a script, which fetches an embedding for our test text &quot; canine &quot;, and then sorts all of our existing texts based on how close in meaning they are to this text. 
  
&amp;lt;?php
include_once(&#039;OpenAIEmbeddingSimpleClient.php&#039;);

//establish DB connection
$GLOBALS[&#039;db_connection&#039;] = mysqli_connect(&#039;localhost&#039;, &#039;root&#039;, &#039;&#039;, &#039;test&#039;) or die(&quot;db connection error&quot;); 
mysqli_query($GLOBALS[&#039;db_connection&#039;], &quot;SET NAMES &#039;utf8&#039;&quot;);


//&quot;canine&quot; embedding, test text
$openAIEmbedding = OpenAIEmbeddingSimpleClient::embeddings(&#039;canine&#039;);

$compareEmbedding = $openAIEmbedding[&#039;data&#039;][0][&#039;embedding&#039;];
foreach($compareEmbedding as $ind =&amp;gt; $v) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$compareEmbedding[$ind] = doubleval($v);
}


//fetch our stored vector database from MySQL/MariaDB
$res = executeQuery(&#039;select * from vectors;&#039;); 
$list = [];

while($row = fetchArray($res)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$similarityScore = cosineSimilarity(explode(&#039;,&#039;, $row[&#039;embedding&#039;]), $compareEmbedding);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$list[] = [
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&#039;text&#039; =&amp;gt; $row[&#039;text&#039;],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&#039;score&#039; =&amp;gt; $similarityScore
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;];
}

usort($list, function($a, $b) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $b[&#039;score&#039;] &amp;lt;=&amp;gt; $a[&#039;score&#039;];
});

print_r($list);
//end of script...


//OpenAI Recommended Algorithm For Comparing Embeddings
function cosineSimilarity($vector1, $vector2) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$dotProduct = 0.0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sqSum1 = 0.0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sqSum2 = 0.0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Performance hack? Stop after 100 comparisons, depending on your data this may be enough
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach($vector1 as $ind =&amp;gt; $d1) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$d1 = doubleval($d1);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$d2 = $vector2[$ind];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$dotProduct += $d1 * $d2;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sqSum1 += $d1 * $d1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sqSum2 += $d2 * $d2;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $dotProduct / (sqrt($sqSum1) * sqrt($sqSum2));
}

//DB helper functions
function dbError(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new Exception(&quot;db_error:&quot;.mysqli_error($GLOBALS[&#039;db_connection&#039;]));
}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
function executeQuery($query){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!is_null($query)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$resultResource = mysqli_query($GLOBALS[&#039;db_connection&#039;], $query);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!$resultResource) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dbError();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(stripos($query, &#039;insert&#039;) === 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return mysqli_insert_id($GLOBALS[&#039;db_connection&#039;]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $resultResource;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new Exception(&quot;query not set&quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}

function fetchArray($resultResource){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return mysqli_fetch_array($resultResource, MYSQLI_ASSOC);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
 
 
 And the following is what the result looks like, if we have a database of 1k existing texts that we want to rank.&amp;nbsp; 
   
 &amp;nbsp; 
 &amp;nbsp; 
 Performance Of Using PHP and MySQL For Vector Databases 
 We did some test benchmarks of the above implementation, and here are the figures: 
 
 For  1,000 vectors  (texts), we are able to rank all of them based on a search query in  0.8 seconds . 
 For  10,000 vectors , the same script runs in  7 seconds . 
 
 &amp;nbsp; 
 It is important to realize, we managed to work with AI vectors, just by using plain vanilla PHP and MySQL.&amp;nbsp; There are other storage systems available now, which have these structures built in -  but these are not necessary to get started . 
 &amp;nbsp; 
 While doing all of this, we discovered a very nice thing! 
 We actually  do not have to compare all 1536 vector values  to still achieve good results!&amp;nbsp;&amp;nbsp; 
 Specifically, just by comparing the first 100 vector values, the ranking did not change, and we were able to process 10k vectors in under 1 second. 
  Pro tip:  to implement this in a performance setting, the comparison function should accept an extra parameter between 0 and 1, stating how much of the vector should be processed. At least from our tests, we found that we do not always have to compare the entire vector. 
 &amp;nbsp; 
 Which Comparison Function Is Best 
 OpenAI recommends to use the  cosine similarity  algorithm, and we also found it to yield the best results. Another algorithm we tried was the  dot product , however we do not recommend it because the performance boost was minimal and the ranking results were considerably worse. 
 In the above code sample, we implemented the cosine similarity function in PHP, and share it with you here. 
 &amp;nbsp; 
 Capabilities Of Vector Embeddings 
 The following are already existing capabilities of using vector embeddings: 
 
  Rank and search  (covered in this tutorial) 
  Grouping and classification  (put similar texts into buckets) 
  Recommendation systems  (show the user top X results) 
  Detect anomalies  (check if a given text or dataset has a completely different semantic meaning) 
  Statistics and distributions  (similar to above, but check if groups of texts fall into normal patterns) 
  Image recognition  (if we transform an image into text first) 
 
 &amp;nbsp; 
 Like with other AI solutions, the challenge still remains for how to collect and format the texts, but this is expected. For example, it may not be worth while to get an embedding for a very long text document, and instead do this on a page-by-page basis, so that when a user does a search, we can forward them to the best matching page within the document. 
 Detecting anomalies is an especially interesting application, and we wonder if it would be possible to separate fake reviews from real ones. This is another major issue in front of many online businesses today. 
 &amp;nbsp; 
 Conclusion 
 Traditional text searching and ranking is based on substrings or keyword search. This has been the dominating methodology for decades, driving all kinds of solutions such as Fuzzy Search, Solr Search and text indexing at the Database level such as MySQL. The biggest challenge of all these systems is, they have a hard time with synonyms and semantic meaning.&amp;nbsp; 
 In the above tutorial we successfully ranked the words &quot;Puppy&quot; and &quot;Dog&quot; as the top results when searching for &quot;Canine&quot;, and we did this by using embedding vectors. The performance is good, and we believe this has the potential to become the next replacement for many search applications.&amp;nbsp; 
 If this tutorial was helpful, then you&#039;ll like the following example, where  we teach an AI to fix email address mistypes . 
 &amp;nbsp; 
                ]]>
            </content>

                            <updated>2023-11-10T00:00:00+01:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">ChatGPT Developer Mode</title>
            <id>https://rockin.ai/blog/generative-ai/chatgpt-developer-mode</id>
            <link href="https://rockin.ai/blog/generative-ai/chatgpt-developer-mode"/>
            <summary type="html">
                <![CDATA[
                
                                            ChatGPT is able to produce decent code, but a good developer will still easily beat it even on simple tasks.
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 Step aside developers, an AI is about to take your spot! Not really, but this is what the news say.&amp;nbsp; 
 First, being developers ourselves, we at rockin.ai love mahcines and artificial intelligence. We love the technology, the breakthroughs and the challenges. One such breakthrough recently was ChatGPT&#039;s ability to write code.&amp;nbsp; 
 We went ahead and did some testing, and will report our findings here.&amp;nbsp; Overall, if we were giving it a grade it would be a C-, which is both disappointing and respectable at the same time. It is respectable because we realize this is only the start, and next versions will no doubt improve! 
 If you are a developer, you should know that  OpenAI has opened up a waitlist for plugin developers . 
 &amp;nbsp; 
 What Is ChatGPT Developer Mode? 
 One of the most hyped capabilities of ChatGPT is its coding skills. Simply asking it to write a piece of code (in any language), will usually result in code being produced. So, enabling developer mode is simply asking  &quot; please write code that solves &amp;lt;insert problem here&amp;gt; &quot; .&amp;nbsp; Let&#039;s have a closer look at the code ChatGPT writes, and see how good it really is. 
 &amp;nbsp; 
 Asking ChatGPT For A Simple Function 
 In the below screenshot, we&#039;re asking ChatGPT to write a function to count all 1s in a binary integer. We have to say it is ironic that we have machine producing human-readable code...&amp;nbsp; 
 While the result actually works, it is also very slow.&amp;nbsp; Maybe this is even the slowest possible implementation.&amp;nbsp; The proposed code from ChatGPT will first convert the integer to a binary string, and then search it for substrings matching &#039;1&#039;. 
   
 &amp;nbsp; 
 Asking ChatGPT For An Optimized Function 
 In an effort to improve the situation, we will ask the same question like before, but ask ChatGPT to optimize the code. We were impressed that ChatGPT immediately realized that using bitwise will make sense.&amp;nbsp; 
 &amp;nbsp; 
   
 &amp;nbsp; 
 &amp;nbsp;&amp;nbsp; 
 Below is the code from ChatGPT so you can also try it out. While it looks like an improvement, ChatGPT forgot that integers can be negative. Also, right-shifting negative numbers in PHP will  not  shift the sign bit, and therefore this becomes an infinite loop! But it was still a nice try.&amp;nbsp; 
  
function countOnes($integer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Irony! Machine writing human code.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$count = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while ($integer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Increment count if the last bit is a one
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$count += $integer &amp;amp; 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Right shift to move to the next bit
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$integer &amp;gt;&amp;gt;= 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $count;
}
 
 
 &amp;nbsp; 
 Writing A Real Solution By Ourselves 
 The real implementation would look more like the one below, where we have to left shift the integer instead (which does shift the sign bit!). Also, we have to remember that some machines have 32 bit integers, and others have 64 bits. The below code is by no means optimal - but at least it is not buggy anymore, and works decently fast. To achieve even faster performance, we can unwrap the loop, and look to hardcode the bitwise operations, probably achieving a near constant runtime - but then the code would barely be readable at all to other developers. 
  
function countOnes($integer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Irony! Human writing Machine Code.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$count = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while ($integer !== 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Increment count if the last bit is a one
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(($integer &amp;amp; PHP_INT_MIN) !== 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$count++;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Left shift to move to the next bit
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$integer &amp;lt;&amp;lt;= 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $count;
}
 
 
 &amp;nbsp; 
 Would We Recommend To Use ChatGPT Code In Production? 
 This depends on the context of the application. If the application has to run perfectly, be decently optimized and secure - then most probably not.&amp;nbsp; At best, the AI might be used as a &quot; co-pilot &quot; and not more than just a code suggestion tool. Its results are easily buggy or slow or both. 
 On the other hand, if the application does not need to be perfect or fast - and is a throw-away app anyway, then definitely yes! The solution proposed by ChatGPT at the very top was working just fine for such a use case.&amp;nbsp; 
 We&#039;ll say for sure,  ChatGPT is much better at cleaning data  than writing code! For example, we have a  separate tutorial about creating a fine-tuned model to fix email addresses . 
 &amp;nbsp; 
 How Does ChatGPT Know What Code To Write? 
 ChatGPT is an LLM under the hood, and it writes code just like it writes essays. It will look for common patterns and try recommending the next most probably word or &quot;token&quot;. The model was likely fed millions of StackOverflow pages to process through, and that is how it is able to come up with logical results. That last part is only a theory by the way, as only the OpenAI team knows how the model was actually trained. 
  &amp;nbsp;  
 Conclusion 
 From our tests, we have to say two things: the results of ChatGPT developing code are poor when comparing to even a bad developer.&amp;nbsp; But! The results are also extremely promising and exciting!&amp;nbsp;&amp;nbsp; 
 Just think about it, if this is only the first iteration of the solution, then what will the next years bring? All comments are welcome below.&amp;nbsp; 
 It may interest you to  connect to the ChatGPT API with a simple client , and do some of these tests in code. 
 &amp;nbsp; 
                ]]>
            </content>

                            <updated>2023-10-31T00:00:00+01:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">ChatGPT Data Analysis and Cleanup Examples</title>
            <id>https://rockin.ai/blog/generative-ai/chatgpt-data-analysis-and-cleanup-examples</id>
            <link href="https://rockin.ai/blog/generative-ai/chatgpt-data-analysis-and-cleanup-examples"/>
            <summary type="html">
                <![CDATA[
                
                                            In this guide, we&#039;ll explore how to harness the power of ChatGPT for basic data tasks. After seeing some of the examples, it&#039;s no wonder the whole world is changing.
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 In this guide, we&#039;ll explore how to harness the power of ChatGPT for data analysis tasks. ChatGPT is a versatile AI model that can assist in a wide range of natural language processing tasks, including text classification, analysis and more. We&#039;ll walk you through the process, step by step, and provide practical examples along the way. 
 &amp;nbsp; 
 Data Analysis 
 Data analysis is both difficult and time consuming. This is especially true in a business environment, where things can often move very slowly. 
 Most probably, the actual job of data analysis isn&#039;t going anywhere soon. LLMs and ChatGPT are great new tools that can be used really by anyone. Below is a screenshot of what&#039;s possible in the free version of ChatGPT today. Please note that in the newer versions of  GPT-4 and up, it is possible to upload PDF files and even Excel . 
   
 &amp;nbsp; 
 What is Data Analysis? 
 Data analysis is the systematic process of examining, cleaning, interpreting, and modeling data to uncover meaningful insights and inform decision-making. It involves collecting, processing, and visualizing data to extract valuable information and patterns, making it a cornerstone of informed actions and discoveries. 
 &amp;nbsp; 
 How to do Data Analysis in ChatGPT? 
 Using the free version of ChatGPT, the data can simply be pasted into the prompt, and questions can be asked.&amp;nbsp; The prompt format goes as follows: 
 
 Provide context for the data - what is it about? 
 Provide the data itself, in the cleanest possible way so ChatGPT can parse it. 
 Ask questions about the data. 
 
 &amp;nbsp; 
 Example Data Analysis Prompt in ChatGPT? 
 Please see the sample prompt below as an example for a data analysis request for ChatGPT: 
   
We are given the following data table of sales during the past 7 days:
weekday, product sold, customer city, sale price
Sunday, Widget1, New York, $100
Sunday, Widget1, San Francisco, $100
Monday, Widget1, New York, $100
Monday, Widget1, San Francisco, $100
Tuesday, Widget1, New York, $100
Tuesday, Widget1, San Francisco, $100
Wednesday, Widget2, New York, $200
Wednesday, Widget1, New York, $100
Wednesday, Widget1, San Francisco, $100
Thursday, Widget1, New York, $100
Friday, Widget2, New York, $200
Saturday, Widget1, New York, $100
Saturday, Widget2, New York, $200

 Which products have the highest demand? 

&amp;nbsp;
&amp;nbsp;
&amp;gt; Based on the provided sales data, it appears that Widget1 and Widget2 are the products being sold. To determine which product has the highest demand, we can analyze the frequency of each product sold:

Widget1 was sold on Sunday, Monday, Tuesday, Wednesday, Thursday, and Saturday.
Widget2 was sold on Wednesday and Friday.
From this analysis,  Widget1 appears to have the highest demand  since it was sold on more days compared to Widget2.
 
 
 &amp;nbsp; 
 Data Cleanup 
 Clean and complete data is a major problem in the &quot;real world&quot;.    Here is a typical scenario:  business might ask their marketing department to create a landing page with a registration of some sort (maybe for a raffle or giveaway). Marketing in turn might copy an existing template, change some content and push it out to their leads. Not too much thought is placed on the data collected, because...  deadline . 
 And some data gets collected over the following weeks... 
 Eventually this new list of customers needs to be used, with all the flawed data that was collected. What could some of these flaws possibly be, you ask? 
 
 People mistyped their information 
 Project scope changed a bit, now you need more data 
 Some obvious data was just missed 
 
 &amp;nbsp; 
 Now, we have a &quot;dirty&quot; set of data, which could take a lot of time and effort to clean up or expand, and this is a real world problem where someone has to manually make adjustments. 
 Please see the screenshot below, of how you can take a simple line of data and actually Generate additional data for it: 
   
 &amp;nbsp; 
 Using ChatGPT to generate user data? 
 Obviously, there are limits to how much data can be generated. For example there&#039;s no way to generate someone&#039;s birthday just using their name and address (or is there...?). 
 However, generating basic knowledge about a customer, by infering from already known information is work wonders if that&#039;s all you need!&amp;nbsp; 
 &amp;nbsp; 
 Correcting User Inputs with ChatGPT 
 We have done a lot of tests on ChatGPT to clean up lists of data.&amp;nbsp; By clean up, we want it to be fixed up for obvious mistypes or misspellings.&amp;nbsp; The results are just stunning, and resemble what a person my do manually! 
 Below is a screenshot, of how ChatGPT can  automatically correct email addresses . Notice how the results is actually very good, given simple prompt to clean the email list. Now, imagine  building an API connection to ChatGPT , and sending all emails to be processed like this! 
   
 &amp;nbsp; 
 Generating New User Data with ChatGPT 
 ChatGPT makes it possible to generate new content based on publicly known information and some current starting point to expand on. In the example below, we request additional address details based on an incomplete address provided by the user: 
    
What is the zip code, telephone area code, country ISO code, for the following address:  &quot;1600 Amphitheatre Parkway in Mountain View, California&quot;?   &amp;gt;  &amp;gt;The information for the address &quot;1600 Amphitheatre Parkway, Mountain View, California&quot; is as follows:
ZIP Code:  94043 
Telephone Area Code:  650 
Country ISO Code:  US  (United States)
 
 
 &amp;nbsp; 
 Conclusion 
 LLMs and ChatGPT in particular have now proven themselves to be capable of many tasks, which would be very time consuming for a mere human to accomplish.  Tapping into these new tools and capabilities deserves a good look, especially now in a world where productivity is paramount. With the above article and provided examples, you should be on a good way to improve your data today. 
 We hope the above tips were helpful, and here are  some more tips on designing good prompts . 
                ]]>
            </content>

                            <updated>2023-10-03T00:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Generative AI vs. Predictive AI: The Distinction</title>
            <id>https://rockin.ai/blog/generative-ai/generative-ai-vs.-predictive-ai-the-distinction</id>
            <link href="https://rockin.ai/blog/generative-ai/generative-ai-vs.-predictive-ai-the-distinction"/>
            <summary type="html">
                <![CDATA[
                
                                            Explore the fascinating world of AI through the lens of generative AI and predictive AI in this in-depth article. Uncover the definitions of these AI branches, their real-world applications in content creation, predictive analytics, and more, and witness how businesses across ...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 The world of artificial intelligence (AI) is teeming with innovation, and two prominent branches,  generative AI  and  predictive AI , stand out with unique capabilities and applications. While both fields contribute to the advancement of AI, they serve distinct purposes and offer different real-world solutions in various industries. In this article, we&#039;ll delve into the definitions of generative and predictive AI, provide real-world examples to illustrate their practical applications, and emphasize the growing significance of these technologies in the business world. 
 &amp;nbsp; 
 Generative AI: Creating from Imagination 
 Generative AI is a fascinating realm of artificial intelligence that revolves around the  creation of new, original content , often by extrapolating from existing data or generating entirely new and unique creations. It is a technology that empowers machines to generate content, whether it be text, images, videos, music, or even entire scenes and landscapes. 
 &amp;nbsp; 
 Definition of Generative AI 
 Generative AI can be defined as a subset of artificial intelligence that focuses on creating content, whether it&#039;s text, images, or other forms of media, often by utilizing existing data patterns and learning to generate content that appears to have been created by humans. 
 Generative AI models are powered by deep learning techniques, particularly variants of neural networks such as Generative Adversarial Networks (GANs) and Transformers. These models learn from vast datasets and generate content by combining, adapting, or even creating data patterns themselves. As an example of transformers in real development,  vector embeddings  are often used to give better search results. 
 &amp;nbsp; 
 Real-World Examples of Generative AI 
  Text-to-Image Generation:  One remarkable application of generative AI is in generating images from text descriptions. For instance, given a textual description like &quot;a serene beach at sunset with palm trees and crashing waves,&quot; generative AI models can produce a corresponding image that aligns with this description. 
  Text-to-Video Generation:  Generative AI can also create videos from  textual prompts . It can turn a written narrative into a visual representation by learning from a dataset of video sequences and applying patterns to construct a coherent video. 
  Artistic Creations:  Generative AI has also made waves in the art world. AI tools like DALL-E have generated artwork based on textual prompts, demonstrating how machines can create art from scratch.  We&#039;re giving away a DALL-E API client &amp;nbsp;to anyone who wants to try this. 
 Generative AI&#039;s remarkable capabilities have found applications in creative fields, content generation, and even in generating realistic synthetic data for various purposes. 
 &amp;nbsp; 
 Predictive AI: Forecasting and Guiding Decisions 
 Predictive AI, on the other hand, is a branch of AI that focuses on  analyzing historical data and patterns to predict future events or outcomes . This technology excels at making informed forecasts and aiding in decision-making processes, often with the aim of improving efficiency, reducing risks, and enhancing customer experiences.&amp;nbsp; 
 &amp;nbsp; 
  Predictive AI concepts are actually used by generative AI, when for example generating an image down at the pixel level, these colors are &quot;predicted&quot; to what will most likely come next. The key differentiation with generative AI is, an entirely new subject is created as the main result.  
 &amp;nbsp; 
 Definition of Predictive AI 
 Predictive AI can be succinctly defined as the application of machine learning and statistical techniques to analyze historical data, identify patterns and trends, and make predictions about future events or outcomes. This technology is widely used in various industries, from finance to marketing and healthcare. 
 Predictive AI employs techniques like regression analysis, time series forecasting, and machine learning algorithms to draw insights from data and provide actionable predictions. These predictions are invaluable for businesses aiming to optimize their operations and anticipate future trends. 
 &amp;nbsp; 
 Real-World Examples of Predictive AI 
  Social Media Click Predictions:  Social media platforms employ predictive AI to anticipate user behavior. By analyzing past interactions and content preferences, they can predict the likelihood of users clicking on specific posts or advertisements. This enables them to optimize content placement and improve user engagement. 
  Fraud Detection in Payment Processing:  Payment processors use predictive AI to detect fraudulent transactions. By analyzing transaction patterns and historical data, they can identify potentially suspicious activities in real-time, preventing financial losses and protecting customers. 
  Product Recommendations in E-commerce:  Shopping websites employ predictive AI to offer personalized product recommendations. By analyzing a user&#039;s past purchases, browsing history, and preferences, these platforms can suggest items that are most likely to pique the user&#039;s interest, increasing sales and enhancing user satisfaction. 
 Predictive AI provides businesses with the means to make data-driven decisions, reduce risks, and enhance customer experiences. It&#039;s a powerful tool that&#039;s being widely adopted in various industries. 
 &amp;nbsp; 
 The Widening Applications of AI 
 Both generative and predictive AI have found their way into countless industries,  transforming the way businesses operate and interact with their customers . The practical applications of these technologies continue to grow, underscoring their importance in the modern world. 
 &amp;nbsp; 
 Generative AI Applications 
 Generative AI&#039;s applications are expanding rapidly, and here are some of the key domains where it is already making a significant impact: 
  Content Creation  
 Generative AI is being used in  content creation and cleanup , automating the generation of written articles, reports, and product descriptions. 
  Image and Video Production  
 In the creative industry, it&#039;s being used to create visual content, such as art, graphics, and video animations. 
  Synthetic Data Generation  
 Generative AI is instrumental in creating synthetic datasets for training machine learning models, enabling data scientists to work with more extensive and diverse data. 
  Programming Code  
  ChatGPT is already capable of writing code , which happens to be another form of generative AI. 
 &amp;nbsp; 
 Predictive AI Applications 
 Predictive AI, too, is making waves across various industries. Here are some applications that highlight its growing significance: 
  Financial Services  
 In finance, predictive AI is utilized for risk assessment, fraud detection, and investment portfolio optimization. 
  Healthcare  
 Predictive AI is used in healthcare for patient diagnosis, treatment planning, and predicting disease outbreaks. 
  Marketing and Advertising  
 It helps businesses personalize marketing strategies, optimize ad targeting, and predict consumer trends. 
  Supply Chain Management  
 Predictive AI assists in forecasting demand, optimizing inventory management, and reducing supply chain inefficiencies. 
  Energy Management  
 In the energy sector, predictive AI is employed to optimize power generation, reduce energy consumption, and enhance grid stability. 
 As both generative and predictive AI technologies mature, their applications will continue to diversify, providing innovative solutions in sectors ranging from healthcare and finance to entertainment and transportation. 
 &amp;nbsp; 
 The Path Forward 
 In conclusion, generative and predictive AI represent two distinct yet complementary facets of the AI landscape. Generative AI offers the power to create content and images from imagination, enabling entirely new creative possibilities. Predictive AI, on the other hand, helps us forecast and make data-driven decisions, making it a valuable tool for optimizing business processes and customer experiences. 
 The adoption of these technologies is growing across various industries, and their significance is only poised to increase in the coming years. As businesses continue to leverage AI for content generation, prediction, and data-driven decision-making, the lines between generative and predictive AI may blur, leading to exciting and innovative applications that benefit us all. The journey of AI is still unfolding, and its potential is boundless. As these technologies advance, they will undoubtedly shape the future of industries, making them more efficient, creative, and productive. 
                ]]>
            </content>

                            <updated>2023-10-02T00:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Unleashing the Power of Language Models (LLM) and AI: A Business Perspective</title>
            <id>https://rockin.ai/blog/generative-ai/unleashing-the-power-of-language-models-llm-and-ai-a-business-perspective</id>
            <link href="https://rockin.ai/blog/generative-ai/unleashing-the-power-of-language-models-llm-and-ai-a-business-perspective"/>
            <summary type="html">
                <![CDATA[
                
                                            Discover how businesses are revolutionizing customer engagement, content creation, and data analysis with cutting-edge AI applications like chatbots, personalized content generation, and predictive analytics. 
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 In the fast-paced world of business, staying ahead of the curve is often a matter of survival. As AI technologies continue to advance, language models have emerged as a game-changer, opening up new frontiers in automation, personalization, and decision-making. In this article, we explore the latest developments in Language Models (LLM) and AI and provide concrete examples of how business leaders can harness these innovations to enhance their operations and gain a competitive edge. 
 &amp;nbsp; 
 The LLM Revolution 
 Language Models, including giants like GPT-3 and GPT-4, have revolutionized the way businesses interact with and harness the power of AI. Here are the latest trends and developments in this space: 
 &amp;nbsp; 
 1. Conversational AI for Customer Engagement 
 Example: Chatbots 
 &amp;nbsp; 
 Conversational AI has reached new heights. Chatbots powered by LLMs can hold natural, context-aware conversations with customers, providing instant support, answering queries, and even assisting in online shopping. The result is improved customer engagement, reduced response times, and higher conversion rates. 
 &amp;nbsp; 
 2. Content Creation and Personalization 
 Example: AI-Generated Content 
 &amp;nbsp; 
 AI is no longer just an assistant; it&#039;s a content creator. AI-generated articles, marketing copy, and even personalized product recommendations are becoming the norm. Businesses are leveraging AI to produce engaging and relevant content at scale, enhancing user experience and marketing strategies. 
 &amp;nbsp; 
 3. Data Analysis and Insights 
 Example: AI-Enhanced Data Analytics 
 &amp;nbsp; 
  LLMs are powering advanced data analysis  and predictive modeling. Businesses can now gain deeper insights into customer behavior, market trends, and operational efficiency. AI-driven data analysis helps in making informed decisions and optimizing strategies. 
 &amp;nbsp; 
 4. Language Translation and Localization 
 Example: Real-time Translation Services 
 &amp;nbsp; 
 Global businesses can expand their reach by offering real-time language translation and localization services. AI-driven translation tools not only break down language barriers but also ensure cultural sensitivity and accuracy, enhancing cross-border communication and sales. 
 &amp;nbsp; 
 5. Improved Search and Recommendation Engines 
 Example:  Enhanced E-commerce Search  
 &amp;nbsp; 
 LLMs are behind the improved search capabilities on e-commerce platforms. Businesses can provide more accurate product search results and personalized recommendations, leading to higher customer satisfaction and conversion rates. 
 &amp;nbsp; 
 AI in Action: Concrete Examples 
 Let&#039;s dive into real-world examples of how businesses are integrating LLM and AI into their operations: 
 &amp;nbsp; 
 1. Healthcare: Personalized Treatment Plans 
 Healthcare providers are using AI to analyze patient data and medical literature to create personalized treatment plans. LLMs help in understanding and interpreting medical records, making it easier for doctors to diagnose, prescribe treatments, and predict patient outcomes. 
 &amp;nbsp; 
 2. E-commerce: Visual Search 
 E-commerce giants are implementing AI-powered visual search. Shoppers can upload images of products they like, and the system finds similar items in the inventory. This personalized shopping experience improves user engagement and drives sales. 
 &amp;nbsp; 
 3. Finance: Fraud Detection 
 Banks and financial institutions are leveraging AI for real-time fraud detection. LLMs can analyze transaction data and user behavior, quickly identifying unusual patterns that may indicate fraudulent activity. This ensures the security of financial transactions. 
 &amp;nbsp; 
 4. Marketing: AI-Driven Advertising 
 Digital marketing relies on AI to target ads to the right audience. LLMs analyze user data, predict user behavior, and serve personalized ads, resulting in higher click-through rates and conversions. 
 &amp;nbsp; 
 5. Manufacturing: Predictive Maintenance 
 Manufacturers use AI for predictive maintenance. Sensors collect data from machinery, which LLMs analyze to predict when equipment might fail. This proactive approach reduces downtime and maintenance costs. 
 &amp;nbsp; 
 Looking Ahead 
 As businesses increasingly integrate  LLM and AI into their operations , the future promises even more exciting developments: 
 &amp;nbsp; 
 1. AI-Assisted Decision-Making 
 AI will become a trusted advisor for executives, providing data-driven insights for strategic decisions. For example, AI can help in  fixing mistyped texts , predicting market trends, and managing resources efficiently. 
 &amp;nbsp; 
 2. AI in Employee Training 
 AI-driven training modules will enhance employee onboarding and skill development. Personalized training programs, including language learning, will become more effective with the assistance of AI. 
 &amp;nbsp; 
 3. AI-Powered Content Moderation 
 AI will play a vital role in content moderation, ensuring a safer and more responsible online environment. LLMs can  identify and filter out harmful or inappropriate content  on platforms. 
 &amp;nbsp; 
 4. Ethical and Responsible AI 
 Businesses are increasingly focusing on ethical AI usage. AI that respects privacy, avoids bias, and adheres to regulations is a growing trend. Companies will prioritize responsible AI practices to build trust with customers and stakeholders. 
 &amp;nbsp; 
 Conclusion 
 The latest developments in Language Models (LLMs) and AI are transforming the business landscape, offering unprecedented opportunities for automation, personalization, and data-driven decision-making. From conversational AI to data analysis and content creation, AI is leaving its mark on various industries. As AI continues to evolve, business leaders who embrace and harness these innovations will be well-positioned for success in the rapidly changing global marketplace. 
 &amp;nbsp; 
 To remain competitive, businesses should stay up to date with the latest trends and explore how AI and LLMs can benefit their specific industry and operations. The potential for growth, efficiency, and innovation is vast, and those who adapt early will reap the rewards of this technological revolution. 
                ]]>
            </content>

                            <updated>2023-08-22T00:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">OpenAI Moderation API Example</title>
            <id>https://rockin.ai/blog/generative-ai/openai-moderation-api-example</id>
            <link href="https://rockin.ai/blog/generative-ai/openai-moderation-api-example"/>
            <summary type="html">
                <![CDATA[
                
                                            OpenAI offers a free moderation API, which will classify texts into undesirable categories. Very helpful to keep your App automatically moderated.
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 Keeping our applications moderated is really a problem when we open them up to the world. Some users will try all kinds of tricks to create an issue or there are also just accidental copy/pastes happening.&amp;nbsp; 
 It is vital to moderate all user inputs with the OpenAI API, and the reason is there are terms of service in effect, which may render an application as undesirable in the ecosystem. This article provides example code, and API requests with responses to demonstrate how moderation works. 
 This is often a missing piece in AI applications, and not even mentioned by most online resources, and that is why we cover it. 
 &amp;nbsp; 
 What Is Content Moderation? 
 One of OpenAI&#039;s main objectives is to make AI safe to use. Hence, any misuse of the tools (such as ChatGPT, DALL-E, Whisper, etc) will result in direct action from OpenAI. We do not really know what this action is, but most likely there may be a ban on the account in question. 
 &amp;nbsp; 
 Simple PHP Client For OpenAI Moderation API 
 Below is an implementation for a very simple PHP client, which you can use to make a connection to the  Moderation API  at OpenAI. We assume you already have a valid API key (if not  this tutorial will guide you ). 
 The moderation API is just a single endpoint where  up to 2000 characters  of text can be sent at a time.    
  
&amp;lt;?php
class OpenAIModerationSimpleClient {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static $open_ai_key = &#039;your-openai-chatgpt-api-key-goes-here&#039;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static $open_ai_url = &#039;https://api.openai.com/v1&#039;; //current version of the API endpoint
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Doc: https://platform.openai.com/docs/api-reference/moderations/create
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param string $input text to classify
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param string $model valid options are &quot;text-moderation-latest&quot;, &quot;text-moderation-stable&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public static function moderate($input, $maxTokens=100, $model=&#039;text-moderation-latest&#039;) { 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//create message to post
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message = new stdClass();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message -&amp;gt; input = $input;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message -&amp;gt; model = $model;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result = self::_sendMessage(&#039;/moderations&#039;, json_encode($message));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $result;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static function _sendMessage($endpoint, $data = &#039;&#039;, $method = &#039;post&#039;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$apiEndpoint = self::$open_ai_url.$endpoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$curl = curl_init();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if($method == &#039;post&#039;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$params = array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_URL =&amp;gt; $apiEndpoint,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYHOST =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_RETURNTRANSFER =&amp;gt; true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_MAXREDIRS =&amp;gt; 10,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_TIMEOUT =&amp;gt; 90,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTP_VERSION =&amp;gt; CURL_HTTP_VERSION_1_1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_CUSTOMREQUEST =&amp;gt; &quot;POST&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_NOBODY =&amp;gt; false, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTPHEADER =&amp;gt; array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;content-type: application/json&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;accept: application/json&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;authorization: Bearer &quot;.self::$open_ai_key
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_setopt_array($curl, $params);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else if($method == &#039;get&#039;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$params = array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_URL =&amp;gt;  $apiEndpoint . ($data!=&#039;&#039;?(&#039;?&#039;.$data):&#039;&#039;),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYHOST =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_RETURNTRANSFER =&amp;gt; true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_MAXREDIRS =&amp;gt; 10,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_TIMEOUT =&amp;gt; 90,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTP_VERSION =&amp;gt; CURL_HTTP_VERSION_1_1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_CUSTOMREQUEST =&amp;gt; &quot;GET&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_NOBODY =&amp;gt; false, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CURLOPT_HTTPHEADER =&amp;gt; array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;content-type: application/json&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;accept: application/json&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &quot;authorization: Bearer &quot;.self::$open_ai_key
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_setopt_array($curl, $params);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$response = curl_exec($curl);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;curl_close($curl);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$data = json_decode($response, true);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!is_array($data)) return array();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $data;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
 
 
 &amp;nbsp; 
 Sending an Example Message to Moderate 
 We will immediately follow up on the simple client, with a simple example using it:&amp;nbsp; 
  
&amp;lt;?php
include_once(&#039;./OpenAIModerationSimpleClient.php&#039;);

$response = OpenAIModerationSimpleClient::moderate(&quot;Hello, how are you?&quot;);

print_r($response);
 
 
 Please remember to place the simple client in the same directory as the test message above.&amp;nbsp; 
 Looking at the response from OpenAI below, note the different moderation classification categories, and we expected the text to pass the moderation check: 
  
Array
(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[id] =&amp;gt; modr-8Gz8koDZPdAr69gYO3tTV9CeUlJBQ
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[model] =&amp;gt; text-moderation-006
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[results] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[0] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[flagged] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[categories] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual/minors] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate/threatening] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence/graphic] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/intent] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/instructions] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment/threatening] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[category_scores] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual] =&amp;gt; 1.3550932635553E-5
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate] =&amp;gt; 2.3837439755425E-7
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment] =&amp;gt; 3.7592290027533E-6
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm] =&amp;gt; 1.7858912571E-8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual/minors] =&amp;gt; 8.3438955300608E-8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate/threatening] =&amp;gt; 6.2585550075767E-9
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence/graphic] =&amp;gt; 2.2840293922854E-7
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/intent] =&amp;gt; 3.4014193683873E-9
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/instructions] =&amp;gt; 4.2348307083273E-9
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment/threatening] =&amp;gt; 9.8226074385366E-8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence] =&amp;gt; 1.6770583215475E-6
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

)
 
 
 &amp;nbsp; 
 What Does a Flagged For Moderation Response Look Like? 
 We will not show the actual request here and leave that up to your imagination, but below is an example flagged response. Notice that &quot; flagged &quot; = true, and this is all that matters. Also, there are further classifications for specific reasons for the flagging, with numeric values for each one.&amp;nbsp; 
 The recommended way to deal with such requests is to just not send them for further processing to OpenAI, and show the user a warning message. 
  

Array
(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[id] =&amp;gt; modr-8Gzba9trAgc4CNsnAYmZ3PSnc0UMb
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[model] =&amp;gt; text-moderation-006
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[results] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[0] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[flagged] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[categories] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual/minors] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate/threatening] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence/graphic] =&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/intent] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/instructions] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment/threatening] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence] =&amp;gt; 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[category_scores] =&amp;gt; Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual] =&amp;gt; 0.0056698704138398
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate] =&amp;gt; 0.0047370679676533
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment] =&amp;gt; 0.99877089262009
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm] =&amp;gt; 0.9786776304245
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[sexual/minors] =&amp;gt; 1.9241338122811E-6
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[hate/threatening] =&amp;gt; 0.00058177195023745
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence/graphic] =&amp;gt; 0.00713293813169
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/intent] =&amp;gt; 0.99002480506897
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[self-harm/instructions] =&amp;gt; 0.98893576860428
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[harassment/threatening] =&amp;gt; 0.51154780387878
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[violence] =&amp;gt; 0.66159009933472
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)

)


  
 &amp;nbsp; 
 How Much Did The OpenAI Moderation API Cost? 
 The OpenAI moderation API is  free . We applaud the OpenAI team for making this decision, and making such a critical part of our applications not only run fast but also cost nothing. At this point there is no excuse to not use it. 
  &amp;nbsp;  
 Conclusion 
 Going through OpenAI&#039;s documentation, we have learned the following about moderation: 
 
 The moderation classification model is continuously being improved 
 Non-English texts have little support, but this is also being improved 
 The &quot; flagged &quot; attribute is what matters most, and we should not rely on the other numeric values (avoid recalibration) 
 
 &amp;nbsp; 
 Hopefully this article has been helpful, especially in the pursuit of building a safe AI application for your users. If you feel like you are ready to create some awesome OpenAI plugins, have a look at how to join the  OpenAI developer waitlist . 
 &amp;nbsp; 
                ]]>
            </content>

                            <updated>2023-08-16T00:00:00+02:00</updated>
                    </entry>

    
</feed>
