APIs for chatGPT available (and how to import it) | Google Cloud Skills Boost Generative ai | Google Introduction to Generative ai | Generative ai Tools for Images | Turtles AI

APIs for chatGPT available (and how to import it)
DukeRem2 March 2023
  OpenAI just released APIs for chatGPT and Whisper, allowing the two services to be incorporated into any app. This can be a turning point. After so much news about chatGPT, we will use it "for real", in millions of apps that can be built on top of it. OpenAI also announced some notable early users of its technology. Namely Snapchat (that introduced My AI for Snapchat+ which offers a chatbot); Quizlet (which introduced Q-Chat, an AI tutor that engages students with adaptive questions); Instacart (that now allows interacting with a bot, asking about food and getting answers); Shop (introducing an AI-based shopping assistant); Speak (introducing a new AI speaking companion product). Many will follow. The most exciting thing is that the cost per token is 1/10 compared to that of using GPT 3 API and accounts for a mere 0.002$. All that is needed is importing and installing OpenAI by some basic commands (here for Python): #Importing openai try:       import openai except:      !pip install openai      import openai   Basically, this code block is used to import the openai library in Python. It first tries to import the openai module, and if the import fails, it installs the openai package using pip and then imports the module. The try block attempts to import the openai module. If the module is already installed, the import statement succeeds, and the module is imported. However, if the module is not installed, the import statement will raise an error. If an error occurs during the import statement, the except block is executed. The except block installs the openai package using pip by running a command with !pip install openai. After installation, it then imports the openai module. This code block is useful for ensuring that the openai package is installed before importing the module. If the package is not installed, the except block will install it, and the import statement in the same block will ensure that the module is imported. If the package is already installed, the try block will simply import the module. This helps ensure that the code can run without interruption due to missing package dependencies.   After that, you need a key for the API and you are set to go. p.s.: also Whisper, the tool for speech-to-text, has been released as an API. It was already available as an open source project.