- Install dependencies
pip install -r requirements.txt
- Create a new
.env
file write API key
OPENAI_API_KEY = '[YOUR_API_KEY]'
Start app
python -m flask --app app.py run
then test
curl --header "Content-Type: application/json" \
--request POST \
--data '{"message":"Hello"}' \
http://127.0.0.1:5000/chat
More detail: Develop an Intelligent Chat Program Using Python and ChatGPT API
py api.py
More detail: Python + ChatGPT API Development | Based on gpt-3.5-turbo model