From the course: Building Apps with AI Tools: ChatGPT, Semantic Kernel, and Langchain

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Connecting to the ChatGPT API

Connecting to the ChatGPT API

- [Instructor] Let's connect to the OpenAI API with Python. I'm here in Codespaces and I'm here on my 01_02 branch. Let's go ahead and create a new virtual environment with the terminal. I'm going to CD into source and then run python -m venv .venv. So there we go. We've created a new virtual environment. Now let's go ahead and go into that environment. We're going to run source .venv/bin/activate. Okay, here we are in our virtual environment. So let's go ahead and install our dependencies. I'm going to run pip install -r requirements. There we go. We've installed the requirements. So let's go ahead and switch our interpreter in the UI. Going to click on the version here, Enter Interpreter Path, Find, click on .venv, bin, and Python 10. Okay, now we're ready to run our code. Let's hit Clear. And now let's go ahead and add our OpenAI key into here. So we're going to head, and under Source, we're going to create a new dot .env…

Contents