From the course: OpenAI API for Python Developers
Start a new project: Quickstart
- [Narrator] So now we start annual projects and you can download the starter projects by cloning the GitHub repository. We're going to follow the steps, which is first, to create a virtual environment, then install the packages, and you simply need to follow the instructions that I am about to give to you. Next, we configure the project by setting up an API key to create completions. And the packages that we use for this project are obviously the OpenAI Python Library. We also use Python-dotenv and this is to define environment variables to keep secrets, sensitive informations like our API key. We also use Tiktoken to keep track of how many tokens we use for every prompt and every completion. And one additional package is Colorama to add color to the output, just to make the common line interface a bit more colorful and fun. And you can also run the script, Python-v to check which version of Python is installed on your machine, or follow this link to follow the steps and install the latest version of Python. So now inside the code editor, I'm using Visual Studio Code to create this program. And the first thing that we're going to run to start this program will be this menu. We're going to display two options, which is the options to ask question or exit the program. So we're going to be able to ask the AI any questions we want. For example, what is the capital of France? What is the capital of Belgium? We can even ask math questions. So before getting started, we're going to need to follow a few instructions that we're going to find here on the README file. First, we want to create a virtual environment, and I am providing instructions for both Windows and Mac. So I'm going to open my terminal and I'm going to run this one. And because I work on a Mac, I'm going to use this script and you're going to see that this is going to create a virtual environment for you, right here. You see that you have this bin directory. Inside, we're going to find also an activate. Here we go. So once this is done, you can then run source to activate your virtual environment, and the next step will be to install all the packages that you're going to find with this file, which is requirements.txt. You see all the dependencies and packages that we use for this project. We're going to install them all. Okay, so once this is done, we can then start our program and you're going to find this script to start your program. So I'm going to use this and you can see also that once the virtual environment is activated, you're going to see this on the left. So let's run this program now and that's going to start the menu. That's going to display the menu with two options. The first one, which is to ask a questions, or the second one, which is to exit the program. So obviously, we want to go ahead and ask away questions to the AI, but first, we're going to configure our project with OpenAI. So we continue next by setting up an API key to authorize API calls.