Python: Using the OpenAI API with InstructGPT
How to query Generative Pre-trained Transformers programmatically.
In recent months (article written Nov 22), Generative Pre-trained Transformers have taken the world by storm. They seem to be the solution to many tasks, but also the epoch of many many headaches. In this quick and simple tutorial, I talk through how to use the OpenAI API in Python and couple it with the text-davinci-003
model.
Installation
We begin by installing the API
!pip install --upgrade openai
API Key
Once we have installed our libraries, we now need to generate an openAI key for our application. We do this by visiting:
This links any requests you make to your user account. It is important you make a note of the key and save it somewhere secure since this will only be shown once.
We now load this into our python program:
import openai
openai.api_key = '<key goes here>'