This is an example pet name generator app used in the OpenAI API quickstart tutorial. It uses the FastAPI web framework. Check out the tutorial or follow the instructions below to get set up. It uses the original Flask example from OpenAI as the base but is built with FastAPI instead of Flask.
-
If you don’t have Python installed, install it from here.
-
Clone this repository.
-
Navigate into the project directory:
$ cd openai-quickstart-python-fastapi -
Create a new virtual environment:
$ python -m venv venv $ . venv/bin/activate -
Install the requirements:
$ pip install -r requirements.txt
-
Make a copy of the example environment variables file:
$ cp .env.example .env
-
Add your API key to the newly created
.envfile. -
Run the app:
$ uvicorn.exe main:app
You should now be able to access the app at http://localhost:8000! For the full context behind this example app, check out the tutorial.