Build Your Own Applications with the OpenAI API

OpenAI Python Library Install the OpenAI Library 1 2 # install from PyPI pip install --upgrade openai Import the relevant Python Libraries and Load the OpenAI API Key If you don’t have an API Key, Get your API Key here. 1 2 3 4 5 6 7 8 import openai import os from dotenv import load_dotenv, find_dotenv _ = load_dotenv(find_dotenv()) # read local .env file openai.api_key = os.getenv('OPENAI_API_KEY') # more secure Here, we use a .env file to store our OpenAI API Key. ...

July 3, 2023 Â· 4 min Â· Da Zhang