Skip to content

ReactMVC/ChatGPT-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT API for Node.js

This repository contains a simple and modern API for interacting with ChatGPT using Node.js. It's fast, free, and easy to use.

Getting Started

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.

Usage

The API provides two endpoints, both of which accept a text parameter:

  • GET /
  • POST /

Fetch

GET
fetch('http://localhost:3000/?text=Hello', {
  method: 'GET',
})
.then(response => response.json())
.then(data => console.log(data));
POST
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
axios.get('http://localhost:3000/', {
  params: {
    text: 'Hello',
  },
})
.then(response => console.log(response.data));
POST
axios.post('http://localhost:3000/', {
  text: 'Hello',
}, {
  headers: {
    'Content-Type': 'application/json; charset=utf-8',
  },
})
.then(response => console.log(response.data));

Contact

For any issues, suggestions, or general feedback, please contact:

Enjoy using the ChatGPT API!

About

fast and free ChatGPT API for node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published