Search⌘ K

Hands-On: Analyze Sentiments Using Text Completions API

Explore how to build a sentiment analyzer using the OpenAI Text Completions API. Learn to identify positive, negative, and neutral sentiments by writing and testing your own code with example sentences.

In this section we will use the OpenAI API to analyze a given piece of text to determine if the sentiment is positive, negative, or neutral.

Creating a sentiment analyzer

Complete the following steps by adding the code to the editor below. Feel free to experiment by changing some things up.

Step 1: Add this variable to store the text that should be ...