This repository contains a simple and modern API for interacting with ChatGPT using Node.js. It's fast, free, and easy to use.
First, clone the repository:
git clone https://github.com/ReactMVC/ChatGPT-API.git
Navigate into the project directory:
cd ChatGPT-API
Install the necessary dependencies:
npm install
Start the server:
node index.js
The server will start running on port 3000.
The API provides two endpoints, both of which accept a text
parameter:
- GET
/
- POST
/
fetch('http://localhost:3000/?text=Hello', {
method: 'GET',
})
.then(response => response.json())
.then(data => console.log(data));
fetch('http://localhost:3000/', {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
body: JSON.stringify({ text: 'Hello' }),
})
.then(response => response.json())
.then(data => console.log(data));
axios.get('http://localhost:3000/', {
params: {
text: 'Hello',
},
})
.then(response => console.log(response.data));
axios.post('http://localhost:3000/', {
text: 'Hello',
}, {
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
})
.then(response => console.log(response.data));
For any issues, suggestions, or general feedback, please contact:
- Name: Hossein Pira
- Email: [email protected]
- Telegram: @h3dev
Enjoy using the ChatGPT API!