Set up OpenAI API
Install the OpenAI Python library
From the terminal / command line, run:
Set up your API key
Create .env
file in the root of your project and add your OpenAI API key:
Run the following command to install the python-dotenv
package:
Add the following code to your Python script to load the API key from the .env
file:
Test your API key
Create a new Python script and add the following code to test your API key:
Last updated