https://github.com/openhacking/chatgpt-api-demo
ChatGPT API Demo
https://github.com/openhacking/chatgpt-api-demo
Last synced: 10 months ago
JSON representation
ChatGPT API Demo
- Host: GitHub
- URL: https://github.com/openhacking/chatgpt-api-demo
- Owner: openHacking
- Created: 2023-03-03T07:49:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-03T07:51:11.000Z (over 3 years ago)
- Last Synced: 2025-03-27T01:48:37.416Z (about 1 year ago)
- Language: Python
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChatGPT API Demo
## Installation
1. Install dependencies
```shell
pip install -r requirements.txt
```
2. Create a new `.env` file
write API key
```shell
OPENAI_API_KEY = '[YOUR_API_KEY]'
```
## Usage
### Use ChatGPT with Flask
Start app
```shell
python -m flask --app app.py run
```
then test
```shell
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](https://lwebapp.com/en/post/python-chatgpt-api)
### Use ChatGPT API
```shell
py api.py
```
More detail: [Python + ChatGPT API Development | Based on gpt-3.5-turbo model](https://lwebapp.com/en/post/chatgpt-api)